diff --git a/README.md b/README.md index 422d910..555b051 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ NOTE: Detailed examples can also be found in the [examples](./examples/) folder. ### Create server connection ```python -import kepconfig.connection +from kepconfig import connection server = connection.server(host = '127.0.0.1', port = 57412, user = 'Administrator', pw = '') @@ -123,7 +123,7 @@ tag_info = [ } ] tag_path = '{}.{}.{}'.format(ch_name, dev_name, tag_group_path) -result = tag.add_tag(server, tag_path, tag_info)) +result = tag.add_tag(server, tag_path, tag_info) ``` diff --git a/docs/kepconfig.html b/docs/kepconfig.html index d78d212..d0d091d 100644 --- a/docs/kepconfig.html +++ b/docs/kepconfig.html @@ -71,6 +71,8 @@
This is a package to help create Python applications to conduct operations with the Kepware Configuration API. This package is designed to work with all versions of Kepware that support the Configuration API including Thingworx Kepware Server (TKS), Thingworx Kepware Edge (TKE) and KEPServerEX (KEP).
+API reference documentation is available on Github Pages
+Package supported and tested on Python 3.9 or later. Older versions support earlier Python 3 environments but have less functionality. All HTTP communication is handled by the urllib Python standard library.
@@ -321,7 +323,6 @@30def add_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 -32 list of endpoints to be added all at once. -33 -34 :param server: instance of the `server` class -35 :param DATA: Dict or List of Dicts of the UA Endpoints to add -36 -37 :return: True - If a "HTTP 201 - Created" is received from Kepware server -38 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -39 endpoints added that failed. -40 -41 :raises KepHTTPError: If urllib provides an HTTPError -42 :raises KepURLError: If urllib provides an URLError -43 ''' -44 -45 r = server._config_add(server.url + _create_url(), DATA) -46 if r.code == 201: return True -47 elif r.code == 207: -48 errors = [] -49 for item in r.payload: -50 if item['code'] != 201: -51 errors.append(item) -52 return errors -53 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -282,21 +283,21 @@31def add_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 +33 list of endpoints to be added all at once. +34 +35 :param server: instance of the `server` class +36 :param DATA: Dict or List of Dicts of the UA Endpoints to add +37 +38 :return: True - If a "HTTP 201 - Created" is received from Kepware server +39 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all +40 endpoints added that failed. +41 +42 :raises KepHTTPError: If urllib provides an HTTPError +43 :raises KepURLError: If urllib provides an URLError +44 ''' +45 +46 r = server._config_add(server.url + _create_url(), DATA) +47 if r.code == 201: return True +48 elif r.code == 207: +49 errors = [] +50 for item in r.payload: +51 if item['code'] != 201: +52 errors.append(item) +53 return errors +54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
55def del_endpoint(server: server, endpoint: str) -> bool: -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 -60 -61 :return: True - If a "HTTP 200 - OK" is received from Kepware server -62 -63 :raises KepHTTPError: If urllib provides an HTTPError -64 :raises KepURLError: If urllib provides an URLError -65 ''' -66 -67 r = server._config_del(server.url + _create_url(endpoint)) -68 if r.code == 200: return True -69 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -336,33 +337,33 @@56def del_endpoint(server: server, endpoint: str) -> bool: +57 '''Delete an `"endpoint"` object in Kepware UA Server +58 +59 :param server: instance of the `server` class +60 :param endpoint: name of endpoint to delete +61 +62 :return: True - If a "HTTP 200 - OK" is received from Kepware server +63 +64 :raises KepHTTPError: If urllib provides an HTTPError +65 :raises KepURLError: If urllib provides an URLError +66 ''' +67 +68 r = server._config_del(server.url + _create_url(endpoint)) +69 if r.code == 200: return True +70 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
71def modify_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, -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 -76 :param server: instance of the `server` class -77 :param DATA: Dict of the UA endpoint properties to be modified. -78 :param endpoint: *(optional)* name of endpoint to modify. Only needed if not existing in `"DATA"` -79 -80 :return: True - If a "HTTP 200 - OK" is received from Kepware server -81 -82 :raises KepHTTPError: If urllib provides an HTTPError -83 :raises KepURLError: If urllib provides an URLError -84 ''' -85 -86 if endpoint == None: -87 try: -88 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) -89 if r.code == 200: return True -90 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -91 except KeyError as err: -92 err_msg = 'Error: No UA Endpoint identified in DATA | Key Error: {}'.format(err) -93 raise KepError(err_msg) -94 else: -95 r = server._config_update(server.url + _create_url(endpoint), DATA) -96 if r.code == 200: return True -97 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -405,20 +406,20 @@72def modify_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, +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 +77 :param server: instance of the `server` class +78 :param DATA: Dict of the UA endpoint properties to be modified. +79 :param endpoint: *(optional)* name of endpoint to modify. Only needed if not existing in `"DATA"` +80 +81 :return: True - If a "HTTP 200 - OK" is received from Kepware server +82 +83 :raises KepHTTPError: If urllib provides an HTTPError +84 :raises KepURLError: If urllib provides an URLError +85 ''' +86 +87 if endpoint == None: +88 try: +89 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) +90 if r.code == 200: return True +91 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +92 except KeyError as err: +93 err_msg = 'Error: No UA Endpoint identified in DATA | Key Error: {}'.format(err) +94 raise KepError(err_msg) +95 else: +96 r = server._config_update(server.url + _create_url(endpoint), DATA) +97 if r.code == 200: return True +98 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
99def get_endpoint(server: server, endpoint: str) -> dict: -100 '''Returns the properties of the `"endpoint"` object. -101 -102 :param server: instance of the `server` class -103 :param endpoint: name of endpoint to retrieve -104 -105 :return: Dict of properties for the UA endpoint requested -106 -107 :raises KepHTTPError: If urllib provides an HTTPError -108 :raises KepURLError: If urllib provides an URLError -109 ''' -110 -111 r = server._config_get(server.url + _create_url(endpoint)) -112 return r.payload +@@ -458,21 +459,21 @@100def get_endpoint(server: server, endpoint: str) -> dict: +101 '''Returns the properties of the `"endpoint"` object. +102 +103 :param server: instance of the `server` class +104 :param endpoint: name of endpoint to retrieve +105 +106 :return: Dict of properties for the UA endpoint requested +107 +108 :raises KepHTTPError: If urllib provides an HTTPError +109 :raises KepURLError: If urllib provides an URLError +110 ''' +111 +112 r = server._config_get(server.url + _create_url(endpoint)) +113 return r.payloadRaises
114def get_all_endpoints(server: server, *, options: dict = None) -> list: -115 '''Returns list of all `"endpoint"` objects and their properties. -116 -117 :param server: instance of the `server` class -118 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of UA endpoints. Options are 'filter', -119 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. -120 -121 :return: List of properties for all UA endpoints requested -122 -123 :raises KepHTTPError: If urllib provides an HTTPError -124 :raises KepURLError: If urllib provides an URLError -125 ''' -126 -127 r = server._config_get(f'{server.url}{_create_url()}', params= options) -128 return r.payload +diff --git a/docs/kepconfig/admin/user_groups.html b/docs/kepconfig/admin/user_groups.html index d6560ae..640760a 100644 --- a/docs/kepconfig/admin/user_groups.html +++ b/docs/kepconfig/admin/user_groups.html @@ -87,150 +87,151 @@115def get_all_endpoints(server: server, *, options: dict = None) -> list: +116 '''Returns list of all `"endpoint"` objects and their properties. +117 +118 :param server: instance of the `server` class +119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of UA endpoints. Options are 'filter', +120 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. +121 +122 :return: List of properties for all UA endpoints requested +123 +124 :raises KepHTTPError: If urllib provides an HTTPError +125 :raises KepURLError: If urllib provides an URLError +126 ''' +127 +128 r = server._config_get(f'{server.url}{_create_url()}', params= options) +129 return r.payload10from typing import Union 11from ..error import KepHTTPError, KepError 12from ..connection import server - 13 + 13from ..utils import _url_parse_object 14 - 15USERGROUPS_ROOT = '/admin/server_usergroups' - 16ENABLE_PROPERTY = 'libadminsettings.USERMANAGER_GROUP_ENABLED' - 17 - 18def _create_url(user_group = None): - 19 '''Creates url object for the "server_usergroups" branch of Kepware's project tree. Used - 20 to build a part of Kepware Configuration API URL structure - 21 - 22 Returns the user group specific url when a value is passed as the user_group name. - 23 ''' - 24 - 25 if user_group == None: - 26 return USERGROUPS_ROOT - 27 else: - 28 return '{}/{}'.format(USERGROUPS_ROOT,user_group) - 29 - 30def add_user_group(server: server, DATA: Union[dict, list]) -> Union[bool, list]: - 31 '''Add a `"user group"` or multiple `"user group"` objects to Kepware User Manager by passing a - 32 list of user groups to be added all at once. - 33 - 34 :param server: instance of the `server` class - 35 :param DATA: Dict or List of Dicts of the user groups to add - 36 - 37 :return: True - If a "HTTP 201 - Created" is received from Kepware server - 38 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all - 39 endpoints added that failed. - 40 - 41 :raises KepHTTPError: If urllib provides an HTTPError - 42 :raises KepURLError: If urllib provides an URLError - 43 ''' - 44 - 45 r = server._config_add(server.url + _create_url(), DATA) - 46 if r.code == 201: return True - 47 elif r.code == 207: - 48 errors = [] - 49 for item in r.payload: - 50 if item['code'] != 201: - 51 errors.append(item) - 52 return errors - 53 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 54 - 55def del_user_group(server: server, user_group: str) -> bool: - 56 '''Delete a `"user group"` object in Kepware User Manager - 57 - 58 :param server: instance of the `server` class - 59 :param user_group: name of user group to delete - 60 - 61 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 62 - 63 :raises KepHTTPError: If urllib provides an HTTPError - 64 :raises KepURLError: If urllib provides an URLError - 65 ''' - 66 - 67 r = server._config_del(server.url + _create_url(user_group)) - 68 if r.code == 200: return True - 69 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 70 - 71def modify_user_group(server: server, DATA: dict, *, user_group: str = None) -> bool: - 72 '''Modify a `"user group"` object and it's properties in Kepware User Manager. If a `"user group"` is not provided as an input, - 73 you need to identify the user group in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 74 assume that is the user group that is to be modified. - 75 - 76 :param server: instance of the `server` class - 77 :param DATA: Dict of the user group properties to be modified. - 78 :param user_group: *(optional)* name of user group to modify. Only needed if not existing in `"DATA"` - 79 - 80 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 81 - 82 :raises KepHTTPError: If urllib provides an HTTPError - 83 :raises KepURLError: If urllib provides an URLError - 84 ''' - 85 - 86 if user_group == None: - 87 try: - 88 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) - 89 if r.code == 200: return True - 90 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 91 except KeyError as err: - 92 err_msg = 'Error: No User Group identified in DATA | Key Error: {}'.format(err) - 93 raise KepError(err_msg) - 94 else: - 95 r = server._config_update(server.url + _create_url(user_group), DATA) - 96 if r.code == 200: return True - 97 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 98 - 99def get_user_group(server: server, user_group: str) -> dict: -100 '''Returns the properties of the `"user group"` object. -101 -102 :param server: instance of the `server` class -103 :param user_group: name of user group to retrieve -104 -105 :return: Dict of properties for the user group requested -106 -107 :raises KepHTTPError: If urllib provides an HTTPError -108 :raises KepURLError: If urllib provides an URLError -109 ''' -110 -111 r = server._config_get(server.url + _create_url(user_group)) -112 return r.payload -113 -114def get_all_user_groups(server: server, *, options: dict = None) -> list: -115 '''Returns list of all `"user group"` objects and their properties. -116 -117 :param server: instance of the `server` class -118 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of user groups. Options are 'filter', -119 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. -120 -121 :return: List of properties for all user groups -122 -123 :raises KepHTTPError: If urllib provides an HTTPError -124 :raises KepURLError: If urllib provides an URLError -125 ''' -126 -127 r = server._config_get(f'{server.url}{_create_url()}', params= options) -128 return r.payload -129 -130def enable_user_group(server: server, user_group: str) -> bool: -131 '''Enable the `"user group"`. -132 -133 :param server: instance of the `server` class -134 :param user_group: name of user group -135 -136 :return: True - If a "HTTP 200 - OK" is received from Kepware server -137 -138 :raises KepHTTPError: If urllib provides an HTTPError -139 :raises KepURLError: If urllib provides an URLError -140 ''' -141 DATA = {ENABLE_PROPERTY: True} -142 return modify_user_group(server, DATA, user_group= user_group) -143 -144def disable_user_group(server: server, user_group: str) -> bool: -145 '''Disable the `"user group"`. -146 -147 :param server: instance of the `server` class -148 :param user_group: name of user group -149 -150 :return: True - If a "HTTP 200 - OK" is received from Kepware server -151 -152 :raises KepHTTPError: If urllib provides an HTTPError -153 :raises KepURLError: If urllib provides an URLError -154 ''' -155 DATA = {ENABLE_PROPERTY: False} -156 return modify_user_group(server, DATA, user_group= user_group) + 15 + 16USERGROUPS_ROOT = '/admin/server_usergroups' + 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 + 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. + 24 ''' + 25 + 26 if user_group == None: + 27 return USERGROUPS_ROOT + 28 else: + 29 return '{}/{}'.format(USERGROUPS_ROOT, _url_parse_object(user_group)) + 30 + 31def add_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 + 33 list of user groups to be added all at once. + 34 + 35 :param server: instance of the `server` class + 36 :param DATA: Dict or List of Dicts of the user groups to add + 37 + 38 :return: True - If a "HTTP 201 - Created" is received from Kepware server + 39 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all + 40 endpoints added that failed. + 41 + 42 :raises KepHTTPError: If urllib provides an HTTPError + 43 :raises KepURLError: If urllib provides an URLError + 44 ''' + 45 + 46 r = server._config_add(server.url + _create_url(), DATA) + 47 if r.code == 201: return True + 48 elif r.code == 207: + 49 errors = [] + 50 for item in r.payload: + 51 if item['code'] != 201: + 52 errors.append(item) + 53 return errors + 54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 55 + 56def del_user_group(server: server, user_group: str) -> bool: + 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 + 61 + 62 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 63 + 64 :raises KepHTTPError: If urllib provides an HTTPError + 65 :raises KepURLError: If urllib provides an URLError + 66 ''' + 67 + 68 r = server._config_del(server.url + _create_url(user_group)) + 69 if r.code == 200: return True + 70 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 71 + 72def modify_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, + 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 + 77 :param server: instance of the `server` class + 78 :param DATA: Dict of the user group properties to be modified. + 79 :param user_group: *(optional)* name of user group to modify. Only needed if not existing in `"DATA"` + 80 + 81 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 82 + 83 :raises KepHTTPError: If urllib provides an HTTPError + 84 :raises KepURLError: If urllib provides an URLError + 85 ''' + 86 + 87 if user_group == None: + 88 try: + 89 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) + 90 if r.code == 200: return True + 91 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 92 except KeyError as err: + 93 err_msg = 'Error: No User Group identified in DATA | Key Error: {}'.format(err) + 94 raise KepError(err_msg) + 95 else: + 96 r = server._config_update(server.url + _create_url(user_group), DATA) + 97 if r.code == 200: return True + 98 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 99 +100def get_user_group(server: server, user_group: str) -> dict: +101 '''Returns the properties of the `"user group"` object. +102 +103 :param server: instance of the `server` class +104 :param user_group: name of user group to retrieve +105 +106 :return: Dict of properties for the user group requested +107 +108 :raises KepHTTPError: If urllib provides an HTTPError +109 :raises KepURLError: If urllib provides an URLError +110 ''' +111 +112 r = server._config_get(server.url + _create_url(user_group)) +113 return r.payload +114 +115def get_all_user_groups(server: server, *, options: dict = None) -> list: +116 '''Returns list of all `"user group"` objects and their properties. +117 +118 :param server: instance of the `server` class +119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of user groups. Options are 'filter', +120 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. +121 +122 :return: List of properties for all user groups +123 +124 :raises KepHTTPError: If urllib provides an HTTPError +125 :raises KepURLError: If urllib provides an URLError +126 ''' +127 +128 r = server._config_get(f'{server.url}{_create_url()}', params= options) +129 return r.payload +130 +131def enable_user_group(server: server, user_group: str) -> bool: +132 '''Enable the `"user group"`. +133 +134 :param server: instance of the `server` class +135 :param user_group: name of user group +136 +137 :return: True - If a "HTTP 200 - OK" is received from Kepware server +138 +139 :raises KepHTTPError: If urllib provides an HTTPError +140 :raises KepURLError: If urllib provides an URLError +141 ''' +142 DATA = {ENABLE_PROPERTY: True} +143 return modify_user_group(server, DATA, user_group= user_group) +144 +145def disable_user_group(server: server, user_group: str) -> bool: +146 '''Disable the `"user group"`. +147 +148 :param server: instance of the `server` class +149 :param user_group: name of user group +150 +151 :return: True - If a "HTTP 200 - OK" is received from Kepware server +152 +153 :raises KepHTTPError: If urllib provides an HTTPError +154 :raises KepURLError: If urllib provides an URLError +155 ''' +156 DATA = {ENABLE_PROPERTY: False} +157 return modify_user_group(server, DATA, user_group= user_group)
31def add_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 -33 list of user groups to be added all at once. -34 -35 :param server: instance of the `server` class -36 :param DATA: Dict or List of Dicts of the user groups to add -37 -38 :return: True - If a "HTTP 201 - Created" is received from Kepware server -39 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -40 endpoints added that failed. -41 -42 :raises KepHTTPError: If urllib provides an HTTPError -43 :raises KepURLError: If urllib provides an URLError -44 ''' -45 -46 r = server._config_add(server.url + _create_url(), DATA) -47 if r.code == 201: return True -48 elif r.code == 207: -49 errors = [] -50 for item in r.payload: -51 if item['code'] != 201: -52 errors.append(item) -53 return errors -54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -317,21 +318,21 @@32def add_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 +34 list of user groups to be added all at once. +35 +36 :param server: instance of the `server` class +37 :param DATA: Dict or List of Dicts of the user groups to add +38 +39 :return: True - If a "HTTP 201 - Created" is received from Kepware server +40 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all +41 endpoints added that failed. +42 +43 :raises KepHTTPError: If urllib provides an HTTPError +44 :raises KepURLError: If urllib provides an URLError +45 ''' +46 +47 r = server._config_add(server.url + _create_url(), DATA) +48 if r.code == 201: return True +49 elif r.code == 207: +50 errors = [] +51 for item in r.payload: +52 if item['code'] != 201: +53 errors.append(item) +54 return errors +55 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
56def del_user_group(server: server, user_group: str) -> bool: -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 -61 -62 :return: True - If a "HTTP 200 - OK" is received from Kepware server -63 -64 :raises KepHTTPError: If urllib provides an HTTPError -65 :raises KepURLError: If urllib provides an URLError -66 ''' -67 -68 r = server._config_del(server.url + _create_url(user_group)) -69 if r.code == 200: return True -70 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -371,33 +372,33 @@57def del_user_group(server: server, user_group: str) -> bool: +58 '''Delete a `"user group"` object in Kepware User Manager +59 +60 :param server: instance of the `server` class +61 :param user_group: name of user group to delete +62 +63 :return: True - If a "HTTP 200 - OK" is received from Kepware server +64 +65 :raises KepHTTPError: If urllib provides an HTTPError +66 :raises KepURLError: If urllib provides an URLError +67 ''' +68 +69 r = server._config_del(server.url + _create_url(user_group)) +70 if r.code == 200: return True +71 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
72def modify_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, -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 -77 :param server: instance of the `server` class -78 :param DATA: Dict of the user group properties to be modified. -79 :param user_group: *(optional)* name of user group to modify. Only needed if not existing in `"DATA"` -80 -81 :return: True - If a "HTTP 200 - OK" is received from Kepware server -82 -83 :raises KepHTTPError: If urllib provides an HTTPError -84 :raises KepURLError: If urllib provides an URLError -85 ''' -86 -87 if user_group == None: -88 try: -89 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) -90 if r.code == 200: return True -91 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -92 except KeyError as err: -93 err_msg = 'Error: No User Group identified in DATA | Key Error: {}'.format(err) -94 raise KepError(err_msg) -95 else: -96 r = server._config_update(server.url + _create_url(user_group), DATA) -97 if r.code == 200: return True -98 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -440,20 +441,20 @@73def modify_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, +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 +78 :param server: instance of the `server` class +79 :param DATA: Dict of the user group properties to be modified. +80 :param user_group: *(optional)* name of user group to modify. Only needed if not existing in `"DATA"` +81 +82 :return: True - If a "HTTP 200 - OK" is received from Kepware server +83 +84 :raises KepHTTPError: If urllib provides an HTTPError +85 :raises KepURLError: If urllib provides an URLError +86 ''' +87 +88 if user_group == None: +89 try: +90 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) +91 if r.code == 200: return True +92 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +93 except KeyError as err: +94 err_msg = 'Error: No User Group identified in DATA | Key Error: {}'.format(err) +95 raise KepError(err_msg) +96 else: +97 r = server._config_update(server.url + _create_url(user_group), DATA) +98 if r.code == 200: return True +99 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
100def get_user_group(server: server, user_group: str) -> dict: -101 '''Returns the properties of the `"user group"` object. -102 -103 :param server: instance of the `server` class -104 :param user_group: name of user group to retrieve -105 -106 :return: Dict of properties for the user group requested -107 -108 :raises KepHTTPError: If urllib provides an HTTPError -109 :raises KepURLError: If urllib provides an URLError -110 ''' -111 -112 r = server._config_get(server.url + _create_url(user_group)) -113 return r.payload +@@ -493,21 +494,21 @@101def get_user_group(server: server, user_group: str) -> dict: +102 '''Returns the properties of the `"user group"` object. +103 +104 :param server: instance of the `server` class +105 :param user_group: name of user group to retrieve +106 +107 :return: Dict of properties for the user group requested +108 +109 :raises KepHTTPError: If urllib provides an HTTPError +110 :raises KepURLError: If urllib provides an URLError +111 ''' +112 +113 r = server._config_get(server.url + _create_url(user_group)) +114 return r.payloadRaises
115def get_all_user_groups(server: server, *, options: dict = None) -> list: -116 '''Returns list of all `"user group"` objects and their properties. -117 -118 :param server: instance of the `server` class -119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of user groups. Options are 'filter', -120 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. -121 -122 :return: List of properties for all user groups -123 -124 :raises KepHTTPError: If urllib provides an HTTPError -125 :raises KepURLError: If urllib provides an URLError -126 ''' -127 -128 r = server._config_get(f'{server.url}{_create_url()}', params= options) -129 return r.payload +@@ -548,19 +549,19 @@116def get_all_user_groups(server: server, *, options: dict = None) -> list: +117 '''Returns list of all `"user group"` objects and their properties. +118 +119 :param server: instance of the `server` class +120 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of user groups. Options are 'filter', +121 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. +122 +123 :return: List of properties for all user groups +124 +125 :raises KepHTTPError: If urllib provides an HTTPError +126 :raises KepURLError: If urllib provides an URLError +127 ''' +128 +129 r = server._config_get(f'{server.url}{_create_url()}', params= options) +130 return r.payloadRaises
131def enable_user_group(server: server, user_group: str) -> bool: -132 '''Enable the `"user group"`. -133 -134 :param server: instance of the `server` class -135 :param user_group: name of user group -136 -137 :return: True - If a "HTTP 200 - OK" is received from Kepware server -138 -139 :raises KepHTTPError: If urllib provides an HTTPError -140 :raises KepURLError: If urllib provides an URLError -141 ''' -142 DATA = {ENABLE_PROPERTY: True} -143 return modify_user_group(server, DATA, user_group= user_group) +@@ -600,19 +601,19 @@132def enable_user_group(server: server, user_group: str) -> bool: +133 '''Enable the `"user group"`. +134 +135 :param server: instance of the `server` class +136 :param user_group: name of user group +137 +138 :return: True - If a "HTTP 200 - OK" is received from Kepware server +139 +140 :raises KepHTTPError: If urllib provides an HTTPError +141 :raises KepURLError: If urllib provides an URLError +142 ''' +143 DATA = {ENABLE_PROPERTY: True} +144 return modify_user_group(server, DATA, user_group= user_group)Raises
145def disable_user_group(server: server, user_group: str) -> bool: -146 '''Disable the `"user group"`. -147 -148 :param server: instance of the `server` class -149 :param user_group: name of user group -150 -151 :return: True - If a "HTTP 200 - OK" is received from Kepware server -152 -153 :raises KepHTTPError: If urllib provides an HTTPError -154 :raises KepURLError: If urllib provides an URLError -155 ''' -156 DATA = {ENABLE_PROPERTY: False} -157 return modify_user_group(server, DATA, user_group= user_group) +diff --git a/docs/kepconfig/admin/users.html b/docs/kepconfig/admin/users.html index 0d03be4..91051fb 100644 --- a/docs/kepconfig/admin/users.html +++ b/docs/kepconfig/admin/users.html @@ -87,150 +87,151 @@146def disable_user_group(server: server, user_group: str) -> bool: +147 '''Disable the `"user group"`. +148 +149 :param server: instance of the `server` class +150 :param user_group: name of user group +151 +152 :return: True - If a "HTTP 200 - OK" is received from Kepware server +153 +154 :raises KepHTTPError: If urllib provides an HTTPError +155 :raises KepURLError: If urllib provides an URLError +156 ''' +157 DATA = {ENABLE_PROPERTY: False} +158 return modify_user_group(server, DATA, user_group= user_group)10from typing import Union 11from ..error import KepError, KepHTTPError 12from ..connection import server - 13 + 13from ..utils import _url_parse_object 14 - 15USERS_ROOT = '/admin/server_users' - 16ENABLE_PROPERTY = 'libadminsettings.USERMANAGER_USER_ENABLED' - 17 - 18def _create_url(user = None): - 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. - 23 ''' - 24 - 25 if user == None: - 26 return USERS_ROOT - 27 else: - 28 return '{}/{}'.format(USERS_ROOT,user) - 29 - 30def add_user(server: server, DATA: Union[dict, list]) -> Union[bool, list]: - 31 '''Add a `"user"` or multiple `"user"` objects to Kepware User Manager by passing a - 32 list of users to be added all at once. - 33 - 34 :param server: instance of the `server` class - 35 :param DATA: Dict or List of Dicts of the users to add - 36 - 37 :return: True - If a "HTTP 201 - Created" is received from Kepware server - 38 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all - 39 endpoints added that failed. - 40 - 41 :raises KepHTTPError: If urllib provides an HTTPError - 42 :raises KepURLError: If urllib provides an URLError - 43 ''' - 44 - 45 r = server._config_add(server.url + _create_url(), DATA) - 46 if r.code == 201: return True - 47 elif r.code == 207: - 48 errors = [] - 49 for item in r.payload: - 50 if item['code'] != 201: - 51 errors.append(item) - 52 return errors - 53 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 54 - 55def del_user(server: server, user: str) -> bool: - 56 '''Delete a `"user"` object in Kepware User Manager - 57 - 58 :param server: instance of the `server` class - 59 :param user: name of user to delete - 60 - 61 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 62 - 63 :raises KepHTTPError: If urllib provides an HTTPError - 64 :raises KepURLError: If urllib provides an URLError - 65 ''' - 66 - 67 r = server._config_del(server.url + _create_url(user)) - 68 if r.code == 200: return True - 69 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 70 - 71def modify_user(server: server , DATA: dict, *, user: str = None) -> bool: - 72 '''Modify a `"user object"` and it's properties in Kepware User Manager. If a `"user"` is not provided as an input, - 73 you need to identify the user in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 74 assume that is the user that is to be modified. - 75 - 76 :param server: instance of the `server` class - 77 :param DATA: Dict of the user properties to be modified. - 78 :param user: *(optional)* name of user to modify. Only needed if not existing in `"DATA"` - 79 - 80 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 81 - 82 :raises KepHTTPError: If urllib provides an HTTPError - 83 :raises KepURLError: If urllib provides an URLError - 84 ''' - 85 - 86 if user == None: - 87 try: - 88 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) - 89 if r.code == 200: return True - 90 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 91 except KeyError as err: - 92 err_msg = 'Error: No User identified in DATA | Key Error: {}'.format(err) - 93 raise KepError(err_msg) - 94 else: - 95 r = server._config_update(server.url + _create_url(user), DATA) - 96 if r.code == 200: return True - 97 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 98 - 99def get_user(server: server, user: str) -> dict: -100 '''Returns the properties of the `"user"` object. -101 -102 :param server: instance of the `server` class -103 :param user: name of user to retrieve -104 -105 :return: Dict of properties for the user requested -106 -107 :raises KepHTTPError: If urllib provides an HTTPError -108 :raises KepURLError: If urllib provides an URLError -109 ''' -110 -111 r = server._config_get(server.url + _create_url(user)) -112 return r.payload -113 -114def get_all_users(server: server, *, options: dict = None) -> list: -115 '''Returns list of all `"user"` objects and their properties. -116 -117 :param server: instance of the `server` class -118 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of users. Options are 'filter', -119 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. -120 -121 :return: List of properties for all users -122 -123 :raises KepHTTPError: If urllib provides an HTTPError -124 :raises KepURLError: If urllib provides an URLError -125 ''' -126 -127 r = server._config_get(f'{server.url}{_create_url()}', params= options) -128 return r.payload -129 -130def enable_user(server: server, user: str) -> bool: -131 '''Enable the `"user"`. -132 -133 :param server: instance of the `server` class -134 :param user: name of user -135 -136 :return: True - If a "HTTP 200 - OK" is received from Kepware server -137 -138 :raises KepHTTPError: If urllib provides an HTTPError -139 :raises KepURLError: If urllib provides an URLError -140 ''' -141 DATA = {ENABLE_PROPERTY: True} -142 return modify_user(server, DATA, user= user) -143 -144def disable_user(server: server, user: str) -> bool: -145 '''Disable the `"user"`. -146 -147 :param server: instance of the `server` class -148 :param user: name of user -149 -150 :return: True - If a "HTTP 200 - OK" is received from Kepware server -151 -152 :raises KepHTTPError: If urllib provides an HTTPError -153 :raises KepURLError: If urllib provides an URLError -154 ''' -155 DATA = {ENABLE_PROPERTY: False} -156 return modify_user(server, DATA, user= user) + 15 + 16USERS_ROOT = '/admin/server_users' + 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 + 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. + 24 ''' + 25 + 26 if user == None: + 27 return USERS_ROOT + 28 else: + 29 return '{}/{}'.format(USERS_ROOT, _url_parse_object(user)) + 30 + 31def add_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 + 33 list of users to be added all at once. + 34 + 35 :param server: instance of the `server` class + 36 :param DATA: Dict or List of Dicts of the users to add + 37 + 38 :return: True - If a "HTTP 201 - Created" is received from Kepware server + 39 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all + 40 endpoints added that failed. + 41 + 42 :raises KepHTTPError: If urllib provides an HTTPError + 43 :raises KepURLError: If urllib provides an URLError + 44 ''' + 45 + 46 r = server._config_add(server.url + _create_url(), DATA) + 47 if r.code == 201: return True + 48 elif r.code == 207: + 49 errors = [] + 50 for item in r.payload: + 51 if item['code'] != 201: + 52 errors.append(item) + 53 return errors + 54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 55 + 56def del_user(server: server, user: str) -> bool: + 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 + 61 + 62 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 63 + 64 :raises KepHTTPError: If urllib provides an HTTPError + 65 :raises KepURLError: If urllib provides an URLError + 66 ''' + 67 + 68 r = server._config_del(server.url + _create_url(user)) + 69 if r.code == 200: return True + 70 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 71 + 72def modify_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, + 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 + 77 :param server: instance of the `server` class + 78 :param DATA: Dict of the user properties to be modified. + 79 :param user: *(optional)* name of user to modify. Only needed if not existing in `"DATA"` + 80 + 81 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 82 + 83 :raises KepHTTPError: If urllib provides an HTTPError + 84 :raises KepURLError: If urllib provides an URLError + 85 ''' + 86 + 87 if user == None: + 88 try: + 89 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) + 90 if r.code == 200: return True + 91 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 92 except KeyError as err: + 93 err_msg = 'Error: No User identified in DATA | Key Error: {}'.format(err) + 94 raise KepError(err_msg) + 95 else: + 96 r = server._config_update(server.url + _create_url(user), DATA) + 97 if r.code == 200: return True + 98 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 99 +100def get_user(server: server, user: str) -> dict: +101 '''Returns the properties of the `"user"` object. +102 +103 :param server: instance of the `server` class +104 :param user: name of user to retrieve +105 +106 :return: Dict of properties for the user requested +107 +108 :raises KepHTTPError: If urllib provides an HTTPError +109 :raises KepURLError: If urllib provides an URLError +110 ''' +111 +112 r = server._config_get(server.url + _create_url(user)) +113 return r.payload +114 +115def get_all_users(server: server, *, options: dict = None) -> list: +116 '''Returns list of all `"user"` objects and their properties. +117 +118 :param server: instance of the `server` class +119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of users. Options are 'filter', +120 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. +121 +122 :return: List of properties for all users +123 +124 :raises KepHTTPError: If urllib provides an HTTPError +125 :raises KepURLError: If urllib provides an URLError +126 ''' +127 +128 r = server._config_get(f'{server.url}{_create_url()}', params= options) +129 return r.payload +130 +131def enable_user(server: server, user: str) -> bool: +132 '''Enable the `"user"`. +133 +134 :param server: instance of the `server` class +135 :param user: name of user +136 +137 :return: True - If a "HTTP 200 - OK" is received from Kepware server +138 +139 :raises KepHTTPError: If urllib provides an HTTPError +140 :raises KepURLError: If urllib provides an URLError +141 ''' +142 DATA = {ENABLE_PROPERTY: True} +143 return modify_user(server, DATA, user= user) +144 +145def disable_user(server: server, user: str) -> bool: +146 '''Disable the `"user"`. +147 +148 :param server: instance of the `server` class +149 :param user: name of user +150 +151 :return: True - If a "HTTP 200 - OK" is received from Kepware server +152 +153 :raises KepHTTPError: If urllib provides an HTTPError +154 :raises KepURLError: If urllib provides an URLError +155 ''' +156 DATA = {ENABLE_PROPERTY: False} +157 return modify_user(server, DATA, user= user)
31def add_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 -33 list of users to be added all at once. -34 -35 :param server: instance of the `server` class -36 :param DATA: Dict or List of Dicts of the users to add -37 -38 :return: True - If a "HTTP 201 - Created" is received from Kepware server -39 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -40 endpoints added that failed. -41 -42 :raises KepHTTPError: If urllib provides an HTTPError -43 :raises KepURLError: If urllib provides an URLError -44 ''' -45 -46 r = server._config_add(server.url + _create_url(), DATA) -47 if r.code == 201: return True -48 elif r.code == 207: -49 errors = [] -50 for item in r.payload: -51 if item['code'] != 201: -52 errors.append(item) -53 return errors -54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -317,21 +318,21 @@32def add_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 +34 list of users to be added all at once. +35 +36 :param server: instance of the `server` class +37 :param DATA: Dict or List of Dicts of the users to add +38 +39 :return: True - If a "HTTP 201 - Created" is received from Kepware server +40 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all +41 endpoints added that failed. +42 +43 :raises KepHTTPError: If urllib provides an HTTPError +44 :raises KepURLError: If urllib provides an URLError +45 ''' +46 +47 r = server._config_add(server.url + _create_url(), DATA) +48 if r.code == 201: return True +49 elif r.code == 207: +50 errors = [] +51 for item in r.payload: +52 if item['code'] != 201: +53 errors.append(item) +54 return errors +55 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
56def del_user(server: server, user: str) -> bool: -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 -61 -62 :return: True - If a "HTTP 200 - OK" is received from Kepware server -63 -64 :raises KepHTTPError: If urllib provides an HTTPError -65 :raises KepURLError: If urllib provides an URLError -66 ''' -67 -68 r = server._config_del(server.url + _create_url(user)) -69 if r.code == 200: return True -70 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -371,33 +372,33 @@57def del_user(server: server, user: str) -> bool: +58 '''Delete a `"user"` object in Kepware User Manager +59 +60 :param server: instance of the `server` class +61 :param user: name of user to delete +62 +63 :return: True - If a "HTTP 200 - OK" is received from Kepware server +64 +65 :raises KepHTTPError: If urllib provides an HTTPError +66 :raises KepURLError: If urllib provides an URLError +67 ''' +68 +69 r = server._config_del(server.url + _create_url(user)) +70 if r.code == 200: return True +71 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
72def modify_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, -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 -77 :param server: instance of the `server` class -78 :param DATA: Dict of the user properties to be modified. -79 :param user: *(optional)* name of user to modify. Only needed if not existing in `"DATA"` -80 -81 :return: True - If a "HTTP 200 - OK" is received from Kepware server -82 -83 :raises KepHTTPError: If urllib provides an HTTPError -84 :raises KepURLError: If urllib provides an URLError -85 ''' -86 -87 if user == None: -88 try: -89 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) -90 if r.code == 200: return True -91 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -92 except KeyError as err: -93 err_msg = 'Error: No User identified in DATA | Key Error: {}'.format(err) -94 raise KepError(err_msg) -95 else: -96 r = server._config_update(server.url + _create_url(user), DATA) -97 if r.code == 200: return True -98 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -440,20 +441,20 @@73def modify_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, +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 +78 :param server: instance of the `server` class +79 :param DATA: Dict of the user properties to be modified. +80 :param user: *(optional)* name of user to modify. Only needed if not existing in `"DATA"` +81 +82 :return: True - If a "HTTP 200 - OK" is received from Kepware server +83 +84 :raises KepHTTPError: If urllib provides an HTTPError +85 :raises KepURLError: If urllib provides an URLError +86 ''' +87 +88 if user == None: +89 try: +90 r = server._config_update(server.url + _create_url(DATA['common.ALLTYPES_NAME']), DATA) +91 if r.code == 200: return True +92 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +93 except KeyError as err: +94 err_msg = 'Error: No User identified in DATA | Key Error: {}'.format(err) +95 raise KepError(err_msg) +96 else: +97 r = server._config_update(server.url + _create_url(user), DATA) +98 if r.code == 200: return True +99 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
100def get_user(server: server, user: str) -> dict: -101 '''Returns the properties of the `"user"` object. -102 -103 :param server: instance of the `server` class -104 :param user: name of user to retrieve -105 -106 :return: Dict of properties for the user requested -107 -108 :raises KepHTTPError: If urllib provides an HTTPError -109 :raises KepURLError: If urllib provides an URLError -110 ''' -111 -112 r = server._config_get(server.url + _create_url(user)) -113 return r.payload +@@ -493,21 +494,21 @@101def get_user(server: server, user: str) -> dict: +102 '''Returns the properties of the `"user"` object. +103 +104 :param server: instance of the `server` class +105 :param user: name of user to retrieve +106 +107 :return: Dict of properties for the user requested +108 +109 :raises KepHTTPError: If urllib provides an HTTPError +110 :raises KepURLError: If urllib provides an URLError +111 ''' +112 +113 r = server._config_get(server.url + _create_url(user)) +114 return r.payloadRaises
115def get_all_users(server: server, *, options: dict = None) -> list: -116 '''Returns list of all `"user"` objects and their properties. -117 -118 :param server: instance of the `server` class -119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of users. Options are 'filter', -120 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. -121 -122 :return: List of properties for all users -123 -124 :raises KepHTTPError: If urllib provides an HTTPError -125 :raises KepURLError: If urllib provides an URLError -126 ''' -127 -128 r = server._config_get(f'{server.url}{_create_url()}', params= options) -129 return r.payload +@@ -548,19 +549,19 @@116def get_all_users(server: server, *, options: dict = None) -> list: +117 '''Returns list of all `"user"` objects and their properties. +118 +119 :param server: instance of the `server` class +120 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of users. Options are 'filter', +121 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize. +122 +123 :return: List of properties for all users +124 +125 :raises KepHTTPError: If urllib provides an HTTPError +126 :raises KepURLError: If urllib provides an URLError +127 ''' +128 +129 r = server._config_get(f'{server.url}{_create_url()}', params= options) +130 return r.payloadRaises
131def enable_user(server: server, user: str) -> bool: -132 '''Enable the `"user"`. -133 -134 :param server: instance of the `server` class -135 :param user: name of user -136 -137 :return: True - If a "HTTP 200 - OK" is received from Kepware server -138 -139 :raises KepHTTPError: If urllib provides an HTTPError -140 :raises KepURLError: If urllib provides an URLError -141 ''' -142 DATA = {ENABLE_PROPERTY: True} -143 return modify_user(server, DATA, user= user) +@@ -600,19 +601,19 @@132def enable_user(server: server, user: str) -> bool: +133 '''Enable the `"user"`. +134 +135 :param server: instance of the `server` class +136 :param user: name of user +137 +138 :return: True - If a "HTTP 200 - OK" is received from Kepware server +139 +140 :raises KepHTTPError: If urllib provides an HTTPError +141 :raises KepURLError: If urllib provides an URLError +142 ''' +143 DATA = {ENABLE_PROPERTY: True} +144 return modify_user(server, DATA, user= user)Raises
145def disable_user(server: server, user: str) -> bool: -146 '''Disable the `"user"`. -147 -148 :param server: instance of the `server` class -149 :param user: name of user -150 -151 :return: True - If a "HTTP 200 - OK" is received from Kepware server -152 -153 :raises KepHTTPError: If urllib provides an HTTPError -154 :raises KepURLError: If urllib provides an URLError -155 ''' -156 DATA = {ENABLE_PROPERTY: False} -157 return modify_user(server, DATA, user= user) +diff --git a/docs/kepconfig/connection.html b/docs/kepconfig/connection.html index 864fd45..8696a17 100644 --- a/docs/kepconfig/connection.html +++ b/docs/kepconfig/connection.html @@ -526,38 +526,40 @@146def disable_user(server: server, user: str) -> bool: +147 '''Disable the `"user"`. +148 +149 :param server: instance of the `server` class +150 :param user: name of user +151 +152 :return: True - If a "HTTP 200 - OK" is received from Kepware server +153 +154 :raises KepHTTPError: If urllib provides an HTTPError +155 :raises KepURLError: If urllib provides an URLError +156 ''' +157 DATA = {ENABLE_PROPERTY: False} +158 return modify_user(server, DATA, user= user)431 # Fucntion used to ensure special characters are handled in the URL 432 # Ex: Space will be turned to %20 433 def __url_validate(self, url): -434 parsed_url = parse.urlparse(url) -435 # Added % for scenarios where special characters have already been escaped with % -436 updated_path = parse.quote(parsed_url.path, safe = '/%') -437 -438 # If host is "localhost", force using the IPv4 loopback adapter IP address in all calls -439 # This is done to remove retries that will happen when the host resolution uses IPv6 intially -440 # Kepware currently doesn't support IPv6 and is not listening on this interface -441 if parsed_url.hostname.lower() == 'localhost': -442 ip = socket.gethostbyname(parsed_url.hostname) -443 parsed_url = parsed_url._replace(netloc='{}:{}'.format(ip, parsed_url.port)) -444 -445 return parsed_url._replace(path=updated_path).geturl() -446 -447 # Function used to build the basic authentication string -448 def __build_auth_str(self, username, password): -449 if isinstance(username, str): -450 username = username.encode('latin1') -451 if isinstance(password, str): -452 password = password.encode('latin1') -453 authstr = b64encode(b':'.join((username, password))).strip().decode('ascii') -454 return authstr -455 -456 # Create parameters for log queries -457 def __create_query(self, start = None, end = None, limit = None): -458 query = {} -459 if start != None and isinstance(start, datetime.datetime): -460 query['start'] = start.isoformat() -461 if end != None and isinstance(end, datetime.datetime): -462 query['end'] = end.isoformat() -463 if limit != None: -464 query['limit'] = limit -465 return query +434 # Configuration API does not use fragments in URL so ignore to allow # as a character +435 # Objects in Kepware can include # as part of the object names +436 parsed_url = parse.urlparse(url, allow_fragments= False) +437 # Added % for scenarios where special characters have already been escaped with % +438 updated_path = parse.quote(parsed_url.path, safe = '/%') +439 +440 # If host is "localhost", force using the IPv4 loopback adapter IP address in all calls +441 # This is done to remove retries that will happen when the host resolution uses IPv6 intially +442 # Kepware currently doesn't support IPv6 and is not listening on this interface +443 if parsed_url.hostname.lower() == 'localhost': +444 ip = socket.gethostbyname(parsed_url.hostname) +445 parsed_url = parsed_url._replace(netloc='{}:{}'.format(ip, parsed_url.port)) +446 +447 return parsed_url._replace(path=updated_path).geturl() +448 +449 # Function used to build the basic authentication string +450 def __build_auth_str(self, username, password): +451 if isinstance(username, str): +452 username = username.encode('latin1') +453 if isinstance(password, str): +454 password = password.encode('latin1') +455 authstr = b64encode(b':'.join((username, password))).strip().decode('ascii') +456 return authstr +457 +458 # Create parameters for log queries +459 def __create_query(self, start = None, end = None, limit = None): +460 query = {} +461 if start != None and isinstance(start, datetime.datetime): +462 query['start'] = start.isoformat() +463 if end != None and isinstance(end, datetime.datetime): +464 query['end'] = end.isoformat() +465 if limit != None: +466 query['limit'] = limit +467 return query
34def add_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 -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 -39 Additionally it can be used to pass a list of channels and it's children to be added all at once. -40 -41 :param server: instance of the `server` class -42 :param DATA: Dict of the channel and it's children -43 expected by Kepware Configuration API -44 -45 :return: True - If a "HTTP 201 - Created" is received from Kepware server -46 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -47 channels added that failed. -48 -49 :raises KepHTTPError: If urllib provides an HTTPError -50 :raises KepURLError: If urllib provides an URLError -51 ''' -52 -53 r = server._config_add(server.url + _create_url(), DATA) -54 if r.code == 201: return True -55 elif r.code == 207: -56 errors = [] -57 for item in r.payload: -58 if item['code'] != 201: -59 errors.append(item) -60 return errors -61 else: -62 raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -356,22 +357,22 @@35def add_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 +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 +40 Additionally it can be used to pass a list of channels and it's children to be added all at once. +41 +42 :param server: instance of the `server` class +43 :param DATA: Dict of the channel and it's children +44 expected by Kepware Configuration API +45 +46 :return: True - If a "HTTP 201 - Created" is received from Kepware server +47 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all +48 channels added that failed. +49 +50 :raises KepHTTPError: If urllib provides an HTTPError +51 :raises KepURLError: If urllib provides an URLError +52 ''' +53 +54 r = server._config_add(server.url + _create_url(), DATA) +55 if r.code == 201: return True +56 elif r.code == 207: +57 errors = [] +58 for item in r.payload: +59 if item['code'] != 201: +60 errors.append(item) +61 return errors +62 else: +63 raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
64def del_channel(server: server, channel: str) -> bool: -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 -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 ''' -75 -76 r = server._config_del(server.url + _create_url(channel)) -77 if r.code == 200: return True -78 else: -79 raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -411,38 +412,38 @@65def del_channel(server: server, channel: str) -> bool: +66 '''Delete a `"channel"` object in Kepware. This will delete all children as well +67 +68 :param server: instance of the `server` class +69 :param channel: name of channel +70 +71 :return: True - If a "HTTP 200 - OK" is received from Kepware server +72 +73 :raises KepHTTPError: If urllib provides an HTTPError +74 :raises KepURLError: If urllib provides an URLError +75 ''' +76 +77 r = server._config_del(server.url + _create_url(channel)) +78 if r.code == 200: return True +79 else: +80 raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
81def modify_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, - 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 - 86 :param server: instance of the `server` class - 87 :param DATA: Dict of the `channel` properties to be modified - 88 :param channel: *(optional)* - name of channel to modify. Only needed if not existing in `"DATA"` - 89 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 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 ''' - 96 - 97 channel_data = server._force_update_check(force, DATA) - 98 if channel == None: - 99 try: -100 r = server._config_update(server.url + _create_url(channel_data['common.ALLTYPES_NAME']), channel_data) -101 if r.code == 200: return True -102 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -103 except KeyError as err: -104 err_msg = 'Error: No Channel identified in DATA | Key Error: {}'.format(err) -105 raise KepError(err_msg) -106 # except Exception as e: -107 # return 'Error: Error with {}: {}'.format(inspect.currentframe().f_code.co_name, str(e)) -108 else: -109 r = server._config_update(server.url + _create_url(channel), channel_data) -110 if r.code == 200: return True -111 else: -112 raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -455,7 +456,7 @@82def modify_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, + 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 + 87 :param server: instance of the `server` class + 88 :param DATA: Dict of the `channel` properties to be modified + 89 :param channel: *(optional)* name of channel to modify. Only needed if not existing in `"DATA"` + 90 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 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 ''' + 97 + 98 channel_data = server._force_update_check(force, DATA) + 99 if channel == None: +100 try: +101 r = server._config_update(server.url + _create_url(channel_data['common.ALLTYPES_NAME']), channel_data) +102 if r.code == 200: return True +103 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +104 except KeyError as err: +105 err_msg = 'Error: No Channel identified in DATA | Key Error: {}'.format(err) +106 raise KepError(err_msg) +107 # except Exception as e: +108 # return 'Error: Error with {}: {}'.format(inspect.currentframe().f_code.co_name, str(e)) +109 else: +110 r = server._config_update(server.url + _create_url(channel), channel_data) +111 if r.code == 200: return True +112 else: +113 raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Parameters
@@ -486,20 +487,20 @@
- server: instance of the
serverclass- DATA: Dict of the
-channelproperties to be modified- channel: (optional) - name of channel to modify. Only needed if not existing in
+"DATA"- channel: (optional) name of channel to modify. Only needed if not existing in
"DATA"- force: (optional) if True, will force the configuration update to the Kepware server
Raises
114def get_channel(server: server, channel: str) -> dict: -115 '''Returns the properties of the channel object. -116 -117 :param server: instance of the `server` class -118 :param channel: name of channel -119 -120 :return: Dict of data for the channel requested -121 -122 :raises KepHTTPError: If urllib provides an HTTPError -123 :raises KepURLError: If urllib provides an URLError -124 ''' -125 -126 r = server._config_get(server.url + _create_url(channel)) -127 return r.payload +@@ -539,21 +540,21 @@115def get_channel(server: server, channel: str) -> dict: +116 '''Returns the properties of the channel object. +117 +118 :param server: instance of the `server` class +119 :param channel: name of channel +120 +121 :return: Dict of data for the channel requested +122 +123 :raises KepHTTPError: If urllib provides an HTTPError +124 :raises KepURLError: If urllib provides an URLError +125 ''' +126 +127 r = server._config_get(server.url + _create_url(channel)) +128 return r.payloadRaises
129def get_all_channels(server: server, *, options: dict = None) -> list: -130 '''Returns list of all channel objects and their properties. -131 -132 :param server: instance of the `server` class -133 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of channels. Options are `filter`, -134 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize` -135 -136 :return: List of data for all channels in Kepware server -137 -138 :raises KepHTTPError: If urllib provides an HTTPError -139 :raises KepURLError: If urllib provides an URLError -140 ''' -141 -142 r = server._config_get(server.url + _create_url(), params= options) -143 return r.payload +@@ -594,52 +595,52 @@130def get_all_channels(server: server, *, options: dict = None) -> list: +131 '''Returns list of all channel objects and their properties. +132 +133 :param server: instance of the `server` class +134 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of channels. Options are `filter`, +135 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize` +136 +137 :return: List of data for all channels in Kepware server +138 +139 :raises KepHTTPError: If urllib provides an HTTPError +140 :raises KepURLError: If urllib provides an URLError +141 ''' +142 +143 r = server._config_get(server.url + _create_url(), params= options) +144 return r.payloadRaises
145def get_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 -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 -150 The returned object resembles the example below, nested based on how many -151 levels the tag_group namespace has tags or tag_groups: -152 -153 Example return: -154 -155 { -156 channel_properties, -157 'devices: [ -158 { -159 device1_properties, -160 'tags': [tag1_dict, tag2_dict,...], -161 'tag_groups':[ -162 { -163 tag_group1_properties, -164 'tags': [tag1_dict, tag2_dict,...] -165 'tag_groups':[sub_group1, subgroup2,...] -166 }, -167 { -168 tag_group2_properties, -169 'tags': [tag1_dict, tag2_dict,...] -170 'tag_groups':[sub_group1, subgroup2,...] -171 },...] -172 },...] -173 } -174 -175 :param server: instance of the `server` class -176 :param channel: name of channel -177 -178 :return: Dict of data for the channel structure requested for `"channel"` -179 -180 :raises KepHTTPError: If urllib provides an HTTPError -181 :raises KepURLError: If urllib provides an URLError -182 ''' -183 -184 channel_properties = get_channel(server, channel) -185 device_list = device.get_all_devices(server,channel) -186 for dev in device_list: -187 device_properties = [] -188 dev_struct = device.get_device_structure(server,channel + '.' + dev['common.ALLTYPES_NAME']) -189 device_properties.append(dev_struct) -190 return {**channel_properties,'device': device_properties} +diff --git a/docs/kepconfig/connectivity/device.html b/docs/kepconfig/connectivity/device.html index 6bde744..b9377f5 100644 --- a/docs/kepconfig/connectivity/device.html +++ b/docs/kepconfig/connectivity/device.html @@ -91,8 +91,8 @@146def get_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 +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 +151 The returned object resembles the example below, nested based on how many +152 levels the tag_group namespace has tags or tag_groups: +153 +154 Example return: +155 +156 { +157 channel_properties, +158 'devices: [ +159 { +160 device1_properties, +161 'tags': [tag1_dict, tag2_dict,...], +162 'tag_groups':[ +163 { +164 tag_group1_properties, +165 'tags': [tag1_dict, tag2_dict,...] +166 'tag_groups':[sub_group1, subgroup2,...] +167 }, +168 { +169 tag_group2_properties, +170 'tags': [tag1_dict, tag2_dict,...] +171 'tag_groups':[sub_group1, subgroup2,...] +172 },...] +173 },...] +174 } +175 +176 :param server: instance of the `server` class +177 :param channel: name of channel +178 +179 :return: Dict of data for the channel structure requested for `"channel"` +180 +181 :raises KepHTTPError: If urllib provides an HTTPError +182 :raises KepURLError: If urllib provides an URLError +183 ''' +184 +185 channel_properties = get_channel(server, channel) +186 device_list = device.get_all_devices(server,channel) +187 for dev in device_list: +188 device_properties = [] +189 dev_struct = device.get_device_structure(server,channel + '.' + dev['common.ALLTYPES_NAME']) +190 device_properties.append(dev_struct) +191 return {**channel_properties,'device': device_properties}11 12from ..connection import KepServiceResponse, server 13from ..error import KepHTTPError, KepError - 14from typing import Union - 15import kepconfig + 14from ..utils import _url_parse_object, path_split + 15from typing import Union 16from . import channel, tag 17import inspect 18 @@ -108,7 +108,7 @@
28 if device == None: 29 return DEVICE_ROOT 30 else: - 31 return '{}/{}'.format(DEVICE_ROOT,device) + 31 return '{}/{}'.format(DEVICE_ROOT,_url_parse_object(device)) 32 33def add_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 @@ -154,7 +154,7 @@
74 :raises KepURLError: If urllib provides an URLError 75 ''' 76 - 77 path_obj = kepconfig.path_split(device_path) + 77 path_obj = path_split(device_path) 78 try: 79 r = server._config_del(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device'])) 80 if r.code == 200: return True @@ -180,7 +180,7 @@
100 101 device_data = server._force_update_check(force, DATA) 102 -103 path_obj = kepconfig.path_split(device_path) +103 path_obj = path_split(device_path) 104 try: 105 r = server._config_update(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device']), device_data) 106 if r.code == 200: return True @@ -202,7 +202,7 @@
122 :raises KepURLError: If urllib provides an URLError 123 ''' 124 -125 path_obj = kepconfig.path_split(device_path) +125 path_obj = path_split(device_path) 126 try: 127 r = server._config_get(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device'])) 128 return r.payload @@ -244,7 +244,7 @@
164 :raises KepURLError: If urllib provides an URLError 165 ''' 166 -167 path_obj = kepconfig.path_split(device_path) +167 path_obj = path_split(device_path) 168 try: 169 url = server.url +channel._create_url(path_obj['channel']) + _create_url(path_obj['device']) + ATG_URL 170 job = server._kep_service_execute(url, None, job_ttl) @@ -438,7 +438,7 @@
Raises
75 :raises KepURLError: If urllib provides an URLError 76 ''' 77 -78 path_obj = kepconfig.path_split(device_path) +78 path_obj = path_split(device_path) 79 try: 80 r = server._config_del(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device'])) 81 if r.code == 200: return True @@ -503,7 +503,7 @@Raises
101 102 device_data = server._force_update_check(force, DATA) 103 -104 path_obj = kepconfig.path_split(device_path) +104 path_obj = path_split(device_path) 105 try: 106 r = server._config_update(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device']), device_data) 107 if r.code == 200: return True @@ -566,7 +566,7 @@Raises
123 :raises KepURLError: If urllib provides an URLError 124 ''' 125 -126 path_obj = kepconfig.path_split(device_path) +126 path_obj = path_split(device_path) 127 try: 128 r = server._config_get(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device'])) 129 return r.payload @@ -687,7 +687,7 @@Raises
165 :raises KepURLError: If urllib provides an URLError 166 ''' 167 -168 path_obj = kepconfig.path_split(device_path) +168 path_obj = path_split(device_path) 169 try: 170 url = server.url +channel._create_url(path_obj['channel']) + _create_url(path_obj['device']) + ATG_URL 171 job = server._kep_service_execute(url, None, job_ttl) diff --git a/docs/kepconfig/connectivity/egd/exchange.html b/docs/kepconfig/connectivity/egd/exchange.html index c4b5d44..1cfff37 100644 --- a/docs/kepconfig/connectivity/egd/exchange.html +++ b/docs/kepconfig/connectivity/egd/exchange.html @@ -80,9 +80,9 @@9exchange objects for EGD devices within the Kepware Configuration API 10""" 11 - 12from ... import path_split - 13from ...connection import server - 14from ...error import KepHTTPError, KepError + 12from ...connection import server + 13from ...error import KepHTTPError, KepError + 14from ...utils import _url_parse_object, path_split 15from typing import Union 16from .. import egd as EGD, channel, device 17 @@ -105,9 +105,9 @@
34 return device_root + PRODUCER_ROOT 35 else: 36 if ex_type.upper() == EGD.CONSUMER_EXCHANGE: - 37 return '{}{}/{}'.format(device_root,CONSUMER_ROOT,exchange_name) + 37 return '{}{}/{}'.format(device_root,CONSUMER_ROOT,_url_parse_object(exchange_name)) 38 else: - 39 return '{}{}/{}'.format(device_root,PRODUCER_ROOT,exchange_name) + 39 return '{}{}/{}'.format(device_root,PRODUCER_ROOT,_url_parse_object(exchange_name)) 40 41def add_exchange(server: server, device_path: str, ex_type: str, DATA: Union[dict, list]) -> Union[bool, list]: 42 '''Add a `"exchange"` or multiple `"exchange"` objects to Kepware. Can be used to pass children of a exchange object diff --git a/docs/kepconfig/connectivity/egd/name.html b/docs/kepconfig/connectivity/egd/name.html index 9cc7610..9c292aa 100644 --- a/docs/kepconfig/connectivity/egd/name.html +++ b/docs/kepconfig/connectivity/egd/name.html @@ -77,7 +77,7 @@
9name resolution objects for EGD devices within the Kepware Configuration API 10""" 11 - 12from ... import path_split + 12from ...utils import _url_parse_object, path_split 13from ...connection import server 14from ...error import KepHTTPError, KepError 15from typing import Union @@ -97,7 +97,7 @@
29 if name == None: 30 return '{}/{}'.format(device_root, NAMES_ROOT) 31 else: - 32 return '{}/{}/{}'.format(device_root, NAMES_ROOT, name) + 32 return '{}/{}/{}'.format(device_root, NAMES_ROOT, _url_parse_object(name)) 33 34def add_name_resolution(server: server, device_path: str, DATA: Union[dict, list]) -> Union[bool, list]: 35 '''Add a `"name resolution"` or multiple `"name resolution"` objects to Kepware. This allows you to diff --git a/docs/kepconfig/connectivity/egd/range.html b/docs/kepconfig/connectivity/egd/range.html index 186df83..5874e47 100644 --- a/docs/kepconfig/connectivity/egd/range.html +++ b/docs/kepconfig/connectivity/egd/range.html @@ -81,131 +81,132 @@
13from .. import egd as EGD 14from ...connection import server 15from ...error import KepError, KepHTTPError - 16 - 17RANGES_ROOT = '/ranges' - 18 - 19def _create_url(device_path, ex_type, exchange_name, range = None): - 20 '''Creates url object for the "range" branch of Kepware's project tree. Used - 21 to build a part of Kepware Configuration API URL structure - 22 - 23 Returns the range specific url when a value is passed as the range name. - 24 ''' - 25 exchange_root = EGD.exchange._create_url(device_path, ex_type, exchange_name) - 26 - 27 if range == None: - 28 return '{}{}'.format(exchange_root, RANGES_ROOT) - 29 else: - 30 return '{}{}/{}'.format(exchange_root, RANGES_ROOT, range) - 31 - 32def add_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: Union[dict, list]) -> Union[bool, list]: - 33 '''Add a `"range"` or multiple `"range"` objects to Kepware. This allows you to - 34 create a range or multiple ranges all in one function, if desired. - 35 - 36 When passing multiple ranges, they will be populated in the same order - 37 in the list sent. Ensure you provide the list in the order desired. - 38 - 39 :param server: instance of the `server` class - 40 :param device_path: path to EGD device. Standard Kepware address decimal - 41 notation string such as `"channel1.device1"` - 42 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` - 43 :param exchange_name: name of exchange that range is located - 44 :param DATA: Dict or List of Dicts of the range(s) to add - 45 - 46 :return: True - If a "HTTP 201 - Created" is received from Kepware server - 47 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all - 48 ranges added that failed. - 49 - 50 :raises KepHTTPError: If urllib provides an HTTPError - 51 :raises KepURLError: If urllib provides an URLError - 52 ''' - 53 - 54 r = server._config_add(server.url + _create_url(device_path, ex_type, exchange_name), DATA) - 55 if r.code == 201: return True - 56 elif r.code == 207: - 57 errors = [] - 58 for item in r.payload: - 59 if item['code'] != 201: - 60 errors.append(item) - 61 return errors - 62 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 63 - 64def del_range(server: server, device_path: str, ex_type: str, exchange_name: str, range_name: str) -> bool: - 65 '''Delete a `"range"` object in Kepware. - 66 - 67 :param server: instance of the `server` class - 68 :param device_path: path to EGD device. Standard Kepware address decimal - 69 notation string such as `"channel1.device1"` - 70 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` - 71 :param exchange_name: name of exchange that range is located - 72 :param range_name: name of range to delete - 73 - 74 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 75 - 76 :raises KepHTTPError: If urllib provides an HTTPError - 77 :raises KepURLError: If urllib provides an URLError - 78 ''' - 79 - 80 r = server._config_del(server.url + _create_url(device_path, ex_type, exchange_name, range_name)) - 81 if r.code == 200: return True - 82 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 83 - 84def modify_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: dict, *, range_name: str = None, force: bool = False) -> bool: - 85 '''Modify a `"range"` object and it's properties in Kepware. If a `"range_name"` is not provided as an input, - 86 you need to identify the range in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 87 assume that is the range that is to be modified. - 88 - 89 :param server: instance of the `server` class - 90 :param device_path: path to EGD device. Standard Kepware address decimal - 91 notation string such as `"channel1.device1"` - 92 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` - 93 :param exchange_name: name of exchange that range is located - 94 :param DATA: Dict of the range properties to be modified. - 95 :param range_name: *(optional)* name of range to to modify. Only needed if not existing in `"DATA"` - 96 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 97 - 98 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 99 -100 :raises KepHTTPError: If urllib provides an HTTPError -101 :raises KepURLError: If urllib provides an URLError -102 ''' -103 -104 range_data = server._force_update_check(force, DATA) -105 if range_name == None: -106 try: -107 r = server._config_update(server.url + _create_url(device_path, ex_type, exchange_name, range_data['common.ALLTYPES_NAME']), range_data) -108 if r.code == 200: return True -109 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -110 except KeyError as err: -111 err_msg = 'Error: No range identified in DATA | Key Error: {}'.format(err) -112 raise KepError(err_msg) -113 else: -114 r = server._config_update(server.url + _create_url(device_path, ex_type, exchange_name, range_name), range_data) -115 if r.code == 200: return True -116 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -117 -118def get_range(server: server, device_path: str, ex_type: str, exchange_name: str, range_name: str = None, *, options: dict = None) -> Union[dict, list]: -119 '''Returns the properties of the `"range"` object or a list of all ranges. -120 -121 :param server: instance of the `server` class -122 :param device_path: path to EGD device. Standard Kepware address decimal -123 notation string such as `"channel1.device1"` -124 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` -125 :param exchange_name: name of exchange that range is located -126 :param DATA: Dict of the range properties to be modified. -127 :param range_name: *(optional)* name of range to retrieve. If not defined, get all ranges -128 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', -129 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when range_name is not defined. -130 -131 :return: Dict of properties for the range requested or a List of ranges and their properties -132 -133 :raises KepHTTPError: If urllib provides an HTTPError -134 :raises KepURLError: If urllib provides an URLError -135 ''' -136 if range_name == None: -137 r = server._config_get(f'{server.url}{_create_url(device_path, ex_type, exchange_name)}', params= options) -138 else: -139 r = server._config_get(f'{server.url}{_create_url(device_path, ex_type, exchange_name, range_name)}') -140 return r.payload + 16from ...utils import _url_parse_object + 17 + 18RANGES_ROOT = '/ranges' + 19 + 20def _create_url(device_path, ex_type, exchange_name, range = None): + 21 '''Creates url object for the "range" branch of Kepware's project tree. Used + 22 to build a part of Kepware Configuration API URL structure + 23 + 24 Returns the range specific url when a value is passed as the range name. + 25 ''' + 26 exchange_root = EGD.exchange._create_url(device_path, ex_type, exchange_name) + 27 + 28 if range == None: + 29 return '{}{}'.format(exchange_root, RANGES_ROOT) + 30 else: + 31 return '{}{}/{}'.format(exchange_root, RANGES_ROOT, _url_parse_object(range)) + 32 + 33def add_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: Union[dict, list]) -> Union[bool, list]: + 34 '''Add a `"range"` or multiple `"range"` objects to Kepware. This allows you to + 35 create a range or multiple ranges all in one function, if desired. + 36 + 37 When passing multiple ranges, they will be populated in the same order + 38 in the list sent. Ensure you provide the list in the order desired. + 39 + 40 :param server: instance of the `server` class + 41 :param device_path: path to EGD device. Standard Kepware address decimal + 42 notation string such as `"channel1.device1"` + 43 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` + 44 :param exchange_name: name of exchange that range is located + 45 :param DATA: Dict or List of Dicts of the range(s) to add + 46 + 47 :return: True - If a "HTTP 201 - Created" is received from Kepware server + 48 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all + 49 ranges added that failed. + 50 + 51 :raises KepHTTPError: If urllib provides an HTTPError + 52 :raises KepURLError: If urllib provides an URLError + 53 ''' + 54 + 55 r = server._config_add(server.url + _create_url(device_path, ex_type, exchange_name), DATA) + 56 if r.code == 201: return True + 57 elif r.code == 207: + 58 errors = [] + 59 for item in r.payload: + 60 if item['code'] != 201: + 61 errors.append(item) + 62 return errors + 63 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 64 + 65def del_range(server: server, device_path: str, ex_type: str, exchange_name: str, range_name: str) -> bool: + 66 '''Delete a `"range"` object in Kepware. + 67 + 68 :param server: instance of the `server` class + 69 :param device_path: path to EGD device. Standard Kepware address decimal + 70 notation string such as `"channel1.device1"` + 71 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` + 72 :param exchange_name: name of exchange that range is located + 73 :param range_name: name of range to delete + 74 + 75 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 76 + 77 :raises KepHTTPError: If urllib provides an HTTPError + 78 :raises KepURLError: If urllib provides an URLError + 79 ''' + 80 + 81 r = server._config_del(server.url + _create_url(device_path, ex_type, exchange_name, range_name)) + 82 if r.code == 200: return True + 83 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 84 + 85def modify_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: dict, *, range_name: str = None, force: bool = False) -> bool: + 86 '''Modify a `"range"` object and it's properties in Kepware. If a `"range_name"` is not provided as an input, + 87 you need to identify the range in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 88 assume that is the range that is to be modified. + 89 + 90 :param server: instance of the `server` class + 91 :param device_path: path to EGD device. Standard Kepware address decimal + 92 notation string such as `"channel1.device1"` + 93 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` + 94 :param exchange_name: name of exchange that range is located + 95 :param DATA: Dict of the range properties to be modified. + 96 :param range_name: *(optional)* name of range to to modify. Only needed if not existing in `"DATA"` + 97 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 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 range_data = server._force_update_check(force, DATA) +106 if range_name == None: +107 try: +108 r = server._config_update(server.url + _create_url(device_path, ex_type, exchange_name, range_data['common.ALLTYPES_NAME']), range_data) +109 if r.code == 200: return True +110 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +111 except KeyError as err: +112 err_msg = 'Error: No range identified in DATA | Key Error: {}'.format(err) +113 raise KepError(err_msg) +114 else: +115 r = server._config_update(server.url + _create_url(device_path, ex_type, exchange_name, range_name), range_data) +116 if r.code == 200: return True +117 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +118 +119def get_range(server: server, device_path: str, ex_type: str, exchange_name: str, range_name: str = None, *, options: dict = None) -> Union[dict, list]: +120 '''Returns the properties of the `"range"` object or a list of all ranges. +121 +122 :param server: instance of the `server` class +123 :param device_path: path to EGD device. Standard Kepware address decimal +124 notation string such as `"channel1.device1"` +125 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` +126 :param exchange_name: name of exchange that range is located +127 :param DATA: Dict of the range properties to be modified. +128 :param range_name: *(optional)* name of range to retrieve. If not defined, get all ranges +129 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', +130 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when range_name is not defined. +131 +132 :return: Dict of properties for the range requested or a List of ranges and their properties +133 +134 :raises KepHTTPError: If urllib provides an HTTPError +135 :raises KepURLError: If urllib provides an URLError +136 ''' +137 if range_name == None: +138 r = server._config_get(f'{server.url}{_create_url(device_path, ex_type, exchange_name)}', params= options) +139 else: +140 r = server._config_get(f'{server.url}{_create_url(device_path, ex_type, exchange_name, range_name)}') +141 return r.payload
33def add_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: Union[dict, list]) -> Union[bool, list]: -34 '''Add a `"range"` or multiple `"range"` objects to Kepware. This allows you to -35 create a range or multiple ranges all in one function, if desired. -36 -37 When passing multiple ranges, they will be populated in the same order -38 in the list sent. Ensure you provide the list in the order desired. -39 -40 :param server: instance of the `server` class -41 :param device_path: path to EGD device. Standard Kepware address decimal -42 notation string such as `"channel1.device1"` -43 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` -44 :param exchange_name: name of exchange that range is located -45 :param DATA: Dict or List of Dicts of the range(s) to add -46 -47 :return: True - If a "HTTP 201 - Created" is received from Kepware server -48 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -49 ranges added that failed. -50 -51 :raises KepHTTPError: If urllib provides an HTTPError -52 :raises KepURLError: If urllib provides an URLError -53 ''' -54 -55 r = server._config_add(server.url + _create_url(device_path, ex_type, exchange_name), DATA) -56 if r.code == 201: return True -57 elif r.code == 207: -58 errors = [] -59 for item in r.payload: -60 if item['code'] != 201: -61 errors.append(item) -62 return errors -63 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -306,25 +307,25 @@34def add_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: Union[dict, list]) -> Union[bool, list]: +35 '''Add a `"range"` or multiple `"range"` objects to Kepware. This allows you to +36 create a range or multiple ranges all in one function, if desired. +37 +38 When passing multiple ranges, they will be populated in the same order +39 in the list sent. Ensure you provide the list in the order desired. +40 +41 :param server: instance of the `server` class +42 :param device_path: path to EGD device. Standard Kepware address decimal +43 notation string such as `"channel1.device1"` +44 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` +45 :param exchange_name: name of exchange that range is located +46 :param DATA: Dict or List of Dicts of the range(s) to add +47 +48 :return: True - If a "HTTP 201 - Created" is received from Kepware server +49 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all +50 ranges added that failed. +51 +52 :raises KepHTTPError: If urllib provides an HTTPError +53 :raises KepURLError: If urllib provides an URLError +54 ''' +55 +56 r = server._config_add(server.url + _create_url(device_path, ex_type, exchange_name), DATA) +57 if r.code == 201: return True +58 elif r.code == 207: +59 errors = [] +60 for item in r.payload: +61 if item['code'] != 201: +62 errors.append(item) +63 return errors +64 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
65def del_range(server: server, device_path: str, ex_type: str, exchange_name: str, range_name: str) -> bool: -66 '''Delete a `"range"` object in Kepware. -67 -68 :param server: instance of the `server` class -69 :param device_path: path to EGD device. Standard Kepware address decimal -70 notation string such as `"channel1.device1"` -71 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` -72 :param exchange_name: name of exchange that range is located -73 :param range_name: name of range to delete -74 -75 :return: True - If a "HTTP 200 - OK" is received from Kepware server -76 -77 :raises KepHTTPError: If urllib provides an HTTPError -78 :raises KepURLError: If urllib provides an URLError -79 ''' -80 -81 r = server._config_del(server.url + _create_url(device_path, ex_type, exchange_name, range_name)) -82 if r.code == 200: return True -83 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -368,39 +369,39 @@66def del_range(server: server, device_path: str, ex_type: str, exchange_name: str, range_name: str) -> bool: +67 '''Delete a `"range"` object in Kepware. +68 +69 :param server: instance of the `server` class +70 :param device_path: path to EGD device. Standard Kepware address decimal +71 notation string such as `"channel1.device1"` +72 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` +73 :param exchange_name: name of exchange that range is located +74 :param range_name: name of range to delete +75 +76 :return: True - If a "HTTP 200 - OK" is received from Kepware server +77 +78 :raises KepHTTPError: If urllib provides an HTTPError +79 :raises KepURLError: If urllib provides an URLError +80 ''' +81 +82 r = server._config_del(server.url + _create_url(device_path, ex_type, exchange_name, range_name)) +83 if r.code == 200: return True +84 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
85def modify_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: dict, *, range_name: str = None, force: bool = False) -> bool: - 86 '''Modify a `"range"` object and it's properties in Kepware. If a `"range_name"` is not provided as an input, - 87 you need to identify the range in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 88 assume that is the range that is to be modified. - 89 - 90 :param server: instance of the `server` class - 91 :param device_path: path to EGD device. Standard Kepware address decimal - 92 notation string such as `"channel1.device1"` - 93 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` - 94 :param exchange_name: name of exchange that range is located - 95 :param DATA: Dict of the range properties to be modified. - 96 :param range_name: *(optional)* name of range to to modify. Only needed if not existing in `"DATA"` - 97 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 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 range_data = server._force_update_check(force, DATA) -106 if range_name == None: -107 try: -108 r = server._config_update(server.url + _create_url(device_path, ex_type, exchange_name, range_data['common.ALLTYPES_NAME']), range_data) -109 if r.code == 200: return True -110 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -111 except KeyError as err: -112 err_msg = 'Error: No range identified in DATA | Key Error: {}'.format(err) -113 raise KepError(err_msg) -114 else: -115 r = server._config_update(server.url + _create_url(device_path, ex_type, exchange_name, range_name), range_data) -116 if r.code == 200: return True -117 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -448,29 +449,29 @@86def modify_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: dict, *, range_name: str = None, force: bool = False) -> bool: + 87 '''Modify a `"range"` object and it's properties in Kepware. If a `"range_name"` is not provided as an input, + 88 you need to identify the range in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 89 assume that is the range that is to be modified. + 90 + 91 :param server: instance of the `server` class + 92 :param device_path: path to EGD device. Standard Kepware address decimal + 93 notation string such as `"channel1.device1"` + 94 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` + 95 :param exchange_name: name of exchange that range is located + 96 :param DATA: Dict of the range properties to be modified. + 97 :param range_name: *(optional)* name of range to to modify. Only needed if not existing in `"DATA"` + 98 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 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 range_data = server._force_update_check(force, DATA) +107 if range_name == None: +108 try: +109 r = server._config_update(server.url + _create_url(device_path, ex_type, exchange_name, range_data['common.ALLTYPES_NAME']), range_data) +110 if r.code == 200: return True +111 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +112 except KeyError as err: +113 err_msg = 'Error: No range identified in DATA | Key Error: {}'.format(err) +114 raise KepError(err_msg) +115 else: +116 r = server._config_update(server.url + _create_url(device_path, ex_type, exchange_name, range_name), range_data) +117 if r.code == 200: return True +118 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
119def get_range(server: server, device_path: str, ex_type: str, exchange_name: str, range_name: str = None, *, options: dict = None) -> Union[dict, list]: -120 '''Returns the properties of the `"range"` object or a list of all ranges. -121 -122 :param server: instance of the `server` class -123 :param device_path: path to EGD device. Standard Kepware address decimal -124 notation string such as `"channel1.device1"` -125 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` -126 :param exchange_name: name of exchange that range is located -127 :param DATA: Dict of the range properties to be modified. -128 :param range_name: *(optional)* name of range to retrieve. If not defined, get all ranges -129 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', -130 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when range_name is not defined. -131 -132 :return: Dict of properties for the range requested or a List of ranges and their properties -133 -134 :raises KepHTTPError: If urllib provides an HTTPError -135 :raises KepURLError: If urllib provides an URLError -136 ''' -137 if range_name == None: -138 r = server._config_get(f'{server.url}{_create_url(device_path, ex_type, exchange_name)}', params= options) -139 else: -140 r = server._config_get(f'{server.url}{_create_url(device_path, ex_type, exchange_name, range_name)}') -141 return r.payload +diff --git a/docs/kepconfig/connectivity/tag.html b/docs/kepconfig/connectivity/tag.html index ccfcf28..a770085 100644 --- a/docs/kepconfig/connectivity/tag.html +++ b/docs/kepconfig/connectivity/tag.html @@ -103,8 +103,8 @@120def get_range(server: server, device_path: str, ex_type: str, exchange_name: str, range_name: str = None, *, options: dict = None) -> Union[dict, list]: +121 '''Returns the properties of the `"range"` object or a list of all ranges. +122 +123 :param server: instance of the `server` class +124 :param device_path: path to EGD device. Standard Kepware address decimal +125 notation string such as `"channel1.device1"` +126 :param ex_type: type of exchange, either `CONSUMER` or `PRODUCER` +127 :param exchange_name: name of exchange that range is located +128 :param DATA: Dict of the range properties to be modified. +129 :param range_name: *(optional)* name of range to retrieve. If not defined, get all ranges +130 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', +131 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when range_name is not defined. +132 +133 :return: Dict of properties for the range requested or a List of ranges and their properties +134 +135 :raises KepHTTPError: If urllib provides an HTTPError +136 :raises KepURLError: If urllib provides an URLError +137 ''' +138 if range_name == None: +139 r = server._config_get(f'{server.url}{_create_url(device_path, ex_type, exchange_name)}', params= options) +140 else: +141 r = server._config_get(f'{server.url}{_create_url(device_path, ex_type, exchange_name, range_name)}') +142 return r.payload11 12from ..connection import server 13from ..error import KepError, KepHTTPError - 14from typing import Union - 15import kepconfig + 14from ..utils import _url_parse_object, path_split + 15from typing import Union 16from . import channel, device 17import inspect 18 @@ -120,7 +120,7 @@
28 if tag == None: 29 return TAGS_ROOT 30 else: - 31 return '{}/{}'.format(TAGS_ROOT,tag) + 31 return '{}/{}'.format(TAGS_ROOT, _url_parse_object(tag)) 32 33def _create_tag_groups_url(tag_group = None): 34 '''Creates url object for the "tag_group" branch of Kepware's project tree. Used @@ -131,7 +131,7 @@
39 if tag_group == None: 40 return TAG_GRP_ROOT 41 else: - 42 return '{}/{}'.format(TAG_GRP_ROOT,tag_group) + 42 return '{}/{}'.format(TAG_GRP_ROOT,_url_parse_object(tag_group)) 43 44def add_tag(server: server, tag_path: str, DATA: Union[dict, list]) -> Union[bool, list]: 45 '''Add `"tag"` or multiple `"tag"` objects to a specific path in Kepware. @@ -150,7 +150,7 @@
58 :raises KepURLError: If urllib provides an URLError 59 ''' 60 - 61 path_obj = kepconfig.path_split(tag_path) + 61 path_obj = path_split(tag_path) 62 try: 63 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 64 if 'tag_path' in path_obj: @@ -191,7 +191,7 @@
99 :raises KepURLError: If urllib provides an URLError 100 ''' 101 -102 path_obj = kepconfig.path_split(tag_group_path) +102 path_obj = path_split(tag_group_path) 103 try: 104 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 105 if 'tag_path' in path_obj: @@ -293,7 +293,7 @@
201 202 tag_data = server._force_update_check(force, DATA) 203 -204 path_obj = kepconfig.path_split(full_tag_path) +204 path_obj = path_split(full_tag_path) 205 try: 206 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 207 for x in range(0, len(path_obj['tag_path'])-1): @@ -326,7 +326,7 @@
234 235 tag_group_data = server._force_update_check(force, DATA) 236 -237 path_obj = kepconfig.path_split(tag_group_path) +237 path_obj = path_split(tag_group_path) 238 try: 239 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 240 for tg in path_obj['tag_path']: @@ -354,7 +354,7 @@
262 :raises KepURLError: If urllib provides an URLError 263 ''' 264 -265 path_obj = kepconfig.path_split(full_tag_path) +265 path_obj = path_split(full_tag_path) 266 try: 267 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 268 for x in range(0, len(path_obj['tag_path'])-1): @@ -383,7 +383,7 @@
291 :raises KepURLError: If urllib provides an URLError 292 ''' 293 -294 path_obj = kepconfig.path_split(tag_group_path) +294 path_obj = path_split(tag_group_path) 295 try: 296 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 297 for tg in path_obj['tag_path']: @@ -411,7 +411,7 @@
319 :raises KepURLError: If urllib provides an URLError 320 ''' 321 -322 path_obj = kepconfig.path_split(full_tag_path) +322 path_obj = path_split(full_tag_path) 323 try: 324 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 325 for x in range(0, len(path_obj['tag_path'])-1): @@ -441,7 +441,7 @@
349 :raises KepURLError: If urllib provides an URLError 350 ''' 351 -352 path_obj = kepconfig.path_split(full_tag_path) +352 path_obj = path_split(full_tag_path) 353 try: 354 url = f"{server.url}{channel._create_url(path_obj['channel'])}{device._create_url(path_obj['device'])}" 355 if 'tag_path' in path_obj: @@ -470,7 +470,7 @@
378 :raises KepHTTPError: If urllib provides an HTTPError 379 :raises KepURLError: If urllib provides an URLError 380 ''' -381 path_obj = kepconfig.path_split(tag_group_path) +381 path_obj = path_split(tag_group_path) 382 try: 383 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 384 for tg in path_obj['tag_path']: @@ -499,7 +499,7 @@
407 :raises KepHTTPError: If urllib provides an HTTPError 408 :raises KepURLError: If urllib provides an URLError 409 ''' -410 path_obj = kepconfig.path_split(tag_group_path) +410 path_obj = path_split(tag_group_path) 411 try: 412 url = f"{server.url}{channel._create_url(path_obj['channel'])}{device._create_url(path_obj['device'])}" 413 if 'tag_path' in path_obj: @@ -607,7 +607,7 @@
59 :raises KepURLError: If urllib provides an URLError 60 ''' 61 -62 path_obj = kepconfig.path_split(tag_path) +62 path_obj = path_split(tag_path) 63 try: 64 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 65 if 'tag_path' in path_obj: @@ -696,7 +696,7 @@
Raises
100 :raises KepURLError: If urllib provides an URLError 101 ''' 102 -103 path_obj = kepconfig.path_split(tag_group_path) +103 path_obj = path_split(tag_group_path) 104 try: 105 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 106 if 'tag_path' in path_obj: @@ -921,7 +921,7 @@Raises
202 203 tag_data = server._force_update_check(force, DATA) 204 -205 path_obj = kepconfig.path_split(full_tag_path) +205 path_obj = path_split(full_tag_path) 206 try: 207 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 208 for x in range(0, len(path_obj['tag_path'])-1): @@ -995,7 +995,7 @@Raises
235 236 tag_group_data = server._force_update_check(force, DATA) 237 -238 path_obj = kepconfig.path_split(tag_group_path) +238 path_obj = path_split(tag_group_path) 239 try: 240 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 241 for tg in path_obj['tag_path']: @@ -1064,7 +1064,7 @@Raises
263 :raises KepURLError: If urllib provides an URLError 264 ''' 265 -266 path_obj = kepconfig.path_split(full_tag_path) +266 path_obj = path_split(full_tag_path) 267 try: 268 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 269 for x in range(0, len(path_obj['tag_path'])-1): @@ -1132,7 +1132,7 @@Raises
292 :raises KepURLError: If urllib provides an URLError 293 ''' 294 -295 path_obj = kepconfig.path_split(tag_group_path) +295 path_obj = path_split(tag_group_path) 296 try: 297 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 298 for tg in path_obj['tag_path']: @@ -1199,7 +1199,7 @@Raises
320 :raises KepURLError: If urllib provides an URLError 321 ''' 322 -323 path_obj = kepconfig.path_split(full_tag_path) +323 path_obj = path_split(full_tag_path) 324 try: 325 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 326 for x in range(0, len(path_obj['tag_path'])-1): @@ -1268,7 +1268,7 @@Raises
379 :raises KepHTTPError: If urllib provides an HTTPError 380 :raises KepURLError: If urllib provides an URLError 381 ''' -382 path_obj = kepconfig.path_split(tag_group_path) +382 path_obj = path_split(tag_group_path) 383 try: 384 url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) 385 for tg in path_obj['tag_path']: @@ -1407,7 +1407,7 @@Raises
408 :raises KepHTTPError: If urllib provides an HTTPError 409 :raises KepURLError: If urllib provides an URLError 410 ''' -411 path_obj = kepconfig.path_split(tag_group_path) +411 path_obj = path_split(tag_group_path) 412 try: 413 url = f"{server.url}{channel._create_url(path_obj['channel'])}{device._create_url(path_obj['device'])}" 414 if 'tag_path' in path_obj: diff --git a/docs/kepconfig/datalogger/log_group.html b/docs/kepconfig/datalogger/log_group.html index 4ac24f2..4f43672 100644 --- a/docs/kepconfig/datalogger/log_group.html +++ b/docs/kepconfig/datalogger/log_group.html @@ -90,167 +90,168 @@10from typing import Union 11from ..connection import KepServiceResponse, server 12from ..error import KepError, KepHTTPError - 13 - 14ENABLE_PROPERTY = 'datalogger.LOG_GROUP_ENABLED' - 15LOG_GROUP_ROOT = '/project/_datalogger/log_groups' - 16SERVICES_ROOT = '/services' - 17def _create_url(log_group = None): - 18 '''Creates url object for the "log_group" branch of Kepware's project tree. Used - 19 to build a part of Kepware Configuration API URL structure - 20 - 21 Returns the agent specific url when a value is passed as the agent name. - 22 ''' - 23 - 24 if log_group == None: - 25 return '{}'.format(LOG_GROUP_ROOT) - 26 else: - 27 return '{}/{}'.format(LOG_GROUP_ROOT, log_group) - 28 + 13from ..utils import _url_parse_object + 14 + 15ENABLE_PROPERTY = 'datalogger.LOG_GROUP_ENABLED' + 16LOG_GROUP_ROOT = '/project/_datalogger/log_groups' + 17SERVICES_ROOT = '/services' + 18def _create_url(log_group = None): + 19 '''Creates url object for the "log_group" branch of Kepware's project tree. Used + 20 to build a part of Kepware Configuration API URL structure + 21 + 22 Returns the agent specific url when a value is passed as the agent name. + 23 ''' + 24 + 25 if log_group == None: + 26 return '{}'.format(LOG_GROUP_ROOT) + 27 else: + 28 return '{}/{}'.format(LOG_GROUP_ROOT, _url_parse_object(log_group)) 29 - 30def add_log_group(server: server, DATA: Union[dict, list]) -> Union[bool, list]: - 31 '''Add a `"log group"` or multiple `"log groups"` objects to Kepware's DataLogger. It can be used - 32 to pass a list of log groups to be added all at once. - 33 - 34 :param server: instance of the `server` class - 35 :param DATA: Dict or a list of the log groups to add through Kepware Configuration API - 36 - 37 :return: True - If a "HTTP 201 - Created" is received from Kepware server - 38 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all - 39 log groups added that failed. - 40 - 41 :raises KepHTTPError: If urllib provides an HTTPError - 42 :raises KepURLError: If urllib provides an URLError - 43 ''' - 44 - 45 r = server._config_add(server.url + _create_url(), DATA) - 46 if r.code == 201: return True - 47 elif r.code == 207: - 48 errors = [] - 49 for item in r.payload: - 50 if item['code'] != 201: - 51 errors.append(item) - 52 return errors - 53 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 54 - 55def del_log_group(server: server, log_group: str) -> bool: - 56 '''Delete a `"log group"` object in Kepware's Datalogger. - 57 - 58 :param server: instance of the `server` class - 59 :param log_group: name of log group to delete - 60 - 61 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 62 - 63 :raises KepHTTPError: If urllib provides an HTTPError - 64 :raises KepURLError: If urllib provides an URLError - 65 ''' - 66 r = server._config_del(server.url + _create_url(log_group)) - 67 if r.code == 200: return True - 68 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 69 - 70def modify_log_group(server: server, DATA: dict, *, log_group: str = None, force: bool = False) -> bool: - 71 '''Modify a `"log group"` object and it's properties in Kepware's Datalogger. If a `"log group"` is not provided as an input, - 72 you need to identify the log group in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 73 assume that is the log group that is to be modified. - 74 - 75 :param server: instance of the `server` class - 76 :param DATA: Dict of the log group properties to be modified. - 77 :param log_group: *(optional)* name of log group to modify. Only needed if not existing in `"DATA"` - 78 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 79 - 80 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 81 - 82 :raises KepHTTPError: If urllib provides an HTTPError - 83 :raises KepURLError: If urllib provides an URLError - 84 ''' - 85 - 86 log_group_data = server._force_update_check(force, DATA) - 87 - 88 if log_group == None: - 89 try: - 90 r = server._config_update(server.url + _create_url(log_group_data['common.ALLTYPES_NAME']), log_group_data) - 91 if r.code == 200: return True - 92 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 93 except KeyError as err: - 94 err_msg = 'Error: No log group identified in DATA | Key Error: {}'.format(err) - 95 raise KepError(err_msg) - 96 else: - 97 r = server._config_update(server.url + _create_url(log_group), log_group_data) - 98 if r.code == 200: return True - 99 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -100 -101def get_log_group(server: server, log_group: str) -> dict: -102 '''Returns the properties of the `"log group"` object. -103 -104 :param server: instance of the `server` class -105 :param log_group: name of log group to retrieve -106 -107 :return: Dict of properties for the log group requested -108 -109 :raises KepHTTPError: If urllib provides an HTTPError -110 :raises KepURLError: If urllib provides an URLError -111 ''' -112 r = server._config_get(server.url + _create_url(log_group)) -113 return r.payload -114 -115def get_all_log_groups(server: server, *, options: dict = None) -> list: -116 '''Returns the properties of all log group objects for Kepware's Datalogger. Returned object is JSON list. -117 -118 :param server: instance of the `server` class -119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', -120 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -121 -122 :return: list of properties for all log groups requested -123 -124 :raises KepHTTPError: If urllib provides an HTTPError -125 :raises KepURLError: If urllib provides an URLError -126 ''' -127 r = server._config_get(f'{server.url}{_create_url()}', params= options) -128 return r.payload -129 -130def enable_log_group(server: server, log_group: str) -> bool: -131 '''Enable the `"log group"`. -132 -133 :param server: instance of the `server` class -134 :param log_group: name of log group to enable -135 -136 :return: True - If a "HTTP 200 - OK" is received from Kepware server -137 -138 :raises KepHTTPError: If urllib provides an HTTPError -139 :raises KepURLError: If urllib provides an URLError -140 ''' -141 DATA = {ENABLE_PROPERTY: True} -142 return modify_log_group(server, DATA, log_group= log_group) -143 -144def disable_log_group(server: server, log_group: str) -> bool: -145 '''Disable the log group. Returned object is JSON. -146 -147 :param server: instance of the `server` class -148 :param log_group: name of log group to enable -149 -150 :return: True - If a "HTTP 200 - OK" is received from Kepware server -151 -152 :raises KepHTTPError: If urllib provides an HTTPError -153 :raises KepURLError: If urllib provides an URLError -154 ''' -155 DATA = {ENABLE_PROPERTY: False} -156 return modify_log_group(server, DATA, log_group= log_group) -157 -158def reset_column_mapping_service(server: server, log_group: str, job_ttl: int = None) -> KepServiceResponse: -159 '''Executes a ResetColumnMapping serivce call to the log group -160 -161 :param server: instance of the `server` class -162 :param log_group: name of log group to enable -163 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion. -164 -165 :return: `KepServiceResponse` instance with job information -166 -167 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned) -168 :raises KepURLError: If urllib provides an URLError -169 ''' -170 -171 url = server.url + _create_url(log_group) + SERVICES_ROOT + '/ResetColumnMapping' -172 job = server._kep_service_execute(url, None, job_ttl) -173 return job + 30 + 31def add_log_group(server: server, DATA: Union[dict, list]) -> Union[bool, list]: + 32 '''Add a `"log group"` or multiple `"log groups"` objects to Kepware's DataLogger. It can be used + 33 to pass a list of log groups to be added all at once. + 34 + 35 :param server: instance of the `server` class + 36 :param DATA: Dict or a list of the log groups to add through Kepware Configuration API + 37 + 38 :return: True - If a "HTTP 201 - Created" is received from Kepware server + 39 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all + 40 log groups added that failed. + 41 + 42 :raises KepHTTPError: If urllib provides an HTTPError + 43 :raises KepURLError: If urllib provides an URLError + 44 ''' + 45 + 46 r = server._config_add(server.url + _create_url(), DATA) + 47 if r.code == 201: return True + 48 elif r.code == 207: + 49 errors = [] + 50 for item in r.payload: + 51 if item['code'] != 201: + 52 errors.append(item) + 53 return errors + 54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 55 + 56def del_log_group(server: server, log_group: str) -> bool: + 57 '''Delete a `"log group"` object in Kepware's Datalogger. + 58 + 59 :param server: instance of the `server` class + 60 :param log_group: name of log group to delete + 61 + 62 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 63 + 64 :raises KepHTTPError: If urllib provides an HTTPError + 65 :raises KepURLError: If urllib provides an URLError + 66 ''' + 67 r = server._config_del(server.url + _create_url(log_group)) + 68 if r.code == 200: return True + 69 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 70 + 71def modify_log_group(server: server, DATA: dict, *, log_group: str = None, force: bool = False) -> bool: + 72 '''Modify a `"log group"` object and it's properties in Kepware's Datalogger. If a `"log group"` is not provided as an input, + 73 you need to identify the log group in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 74 assume that is the log group that is to be modified. + 75 + 76 :param server: instance of the `server` class + 77 :param DATA: Dict of the log group properties to be modified. + 78 :param log_group: *(optional)* name of log group to modify. Only needed if not existing in `"DATA"` + 79 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 80 + 81 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 82 + 83 :raises KepHTTPError: If urllib provides an HTTPError + 84 :raises KepURLError: If urllib provides an URLError + 85 ''' + 86 + 87 log_group_data = server._force_update_check(force, DATA) + 88 + 89 if log_group == None: + 90 try: + 91 r = server._config_update(server.url + _create_url(log_group_data['common.ALLTYPES_NAME']), log_group_data) + 92 if r.code == 200: return True + 93 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 94 except KeyError as err: + 95 err_msg = 'Error: No log group identified in DATA | Key Error: {}'.format(err) + 96 raise KepError(err_msg) + 97 else: + 98 r = server._config_update(server.url + _create_url(log_group), log_group_data) + 99 if r.code == 200: return True +100 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +101 +102def get_log_group(server: server, log_group: str) -> dict: +103 '''Returns the properties of the `"log group"` object. +104 +105 :param server: instance of the `server` class +106 :param log_group: name of log group to retrieve +107 +108 :return: Dict of properties for the log group requested +109 +110 :raises KepHTTPError: If urllib provides an HTTPError +111 :raises KepURLError: If urllib provides an URLError +112 ''' +113 r = server._config_get(server.url + _create_url(log_group)) +114 return r.payload +115 +116def get_all_log_groups(server: server, *, options: dict = None) -> list: +117 '''Returns the properties of all log group objects for Kepware's Datalogger. Returned object is JSON list. +118 +119 :param server: instance of the `server` class +120 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', +121 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +122 +123 :return: list of properties for all log groups requested +124 +125 :raises KepHTTPError: If urllib provides an HTTPError +126 :raises KepURLError: If urllib provides an URLError +127 ''' +128 r = server._config_get(f'{server.url}{_create_url()}', params= options) +129 return r.payload +130 +131def enable_log_group(server: server, log_group: str) -> bool: +132 '''Enable the `"log group"`. +133 +134 :param server: instance of the `server` class +135 :param log_group: name of log group to enable +136 +137 :return: True - If a "HTTP 200 - OK" is received from Kepware server +138 +139 :raises KepHTTPError: If urllib provides an HTTPError +140 :raises KepURLError: If urllib provides an URLError +141 ''' +142 DATA = {ENABLE_PROPERTY: True} +143 return modify_log_group(server, DATA, log_group= log_group) +144 +145def disable_log_group(server: server, log_group: str) -> bool: +146 '''Disable the log group. Returned object is JSON. +147 +148 :param server: instance of the `server` class +149 :param log_group: name of log group to enable +150 +151 :return: True - If a "HTTP 200 - OK" is received from Kepware server +152 +153 :raises KepHTTPError: If urllib provides an HTTPError +154 :raises KepURLError: If urllib provides an URLError +155 ''' +156 DATA = {ENABLE_PROPERTY: False} +157 return modify_log_group(server, DATA, log_group= log_group) +158 +159def reset_column_mapping_service(server: server, log_group: str, job_ttl: int = None) -> KepServiceResponse: +160 '''Executes a ResetColumnMapping serivce call to the log group +161 +162 :param server: instance of the `server` class +163 :param log_group: name of log group to enable +164 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion. +165 +166 :return: `KepServiceResponse` instance with job information +167 +168 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned) +169 :raises KepURLError: If urllib provides an URLError +170 ''' +171 +172 url = server.url + _create_url(log_group) + SERVICES_ROOT + '/ResetColumnMapping' +173 job = server._kep_service_execute(url, None, job_ttl) +174 return job
31def add_log_group(server: server, DATA: Union[dict, list]) -> Union[bool, list]: -32 '''Add a `"log group"` or multiple `"log groups"` objects to Kepware's DataLogger. It can be used -33 to pass a list of log groups to be added all at once. -34 -35 :param server: instance of the `server` class -36 :param DATA: Dict or a list of the log groups to add through Kepware Configuration API -37 -38 :return: True - If a "HTTP 201 - Created" is received from Kepware server -39 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -40 log groups added that failed. -41 -42 :raises KepHTTPError: If urllib provides an HTTPError -43 :raises KepURLError: If urllib provides an URLError -44 ''' -45 -46 r = server._config_add(server.url + _create_url(), DATA) -47 if r.code == 201: return True -48 elif r.code == 207: -49 errors = [] -50 for item in r.payload: -51 if item['code'] != 201: -52 errors.append(item) -53 return errors -54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -337,20 +338,20 @@32def add_log_group(server: server, DATA: Union[dict, list]) -> Union[bool, list]: +33 '''Add a `"log group"` or multiple `"log groups"` objects to Kepware's DataLogger. It can be used +34 to pass a list of log groups to be added all at once. +35 +36 :param server: instance of the `server` class +37 :param DATA: Dict or a list of the log groups to add through Kepware Configuration API +38 +39 :return: True - If a "HTTP 201 - Created" is received from Kepware server +40 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all +41 log groups added that failed. +42 +43 :raises KepHTTPError: If urllib provides an HTTPError +44 :raises KepURLError: If urllib provides an URLError +45 ''' +46 +47 r = server._config_add(server.url + _create_url(), DATA) +48 if r.code == 201: return True +49 elif r.code == 207: +50 errors = [] +51 for item in r.payload: +52 if item['code'] != 201: +53 errors.append(item) +54 return errors +55 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
56def del_log_group(server: server, log_group: str) -> bool: -57 '''Delete a `"log group"` object in Kepware's Datalogger. -58 -59 :param server: instance of the `server` class -60 :param log_group: name of log group to delete -61 -62 :return: True - If a "HTTP 200 - OK" is received from Kepware server -63 -64 :raises KepHTTPError: If urllib provides an HTTPError -65 :raises KepURLError: If urllib provides an URLError -66 ''' -67 r = server._config_del(server.url + _create_url(log_group)) -68 if r.code == 200: return True -69 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -390,36 +391,36 @@57def del_log_group(server: server, log_group: str) -> bool: +58 '''Delete a `"log group"` object in Kepware's Datalogger. +59 +60 :param server: instance of the `server` class +61 :param log_group: name of log group to delete +62 +63 :return: True - If a "HTTP 200 - OK" is received from Kepware server +64 +65 :raises KepHTTPError: If urllib provides an HTTPError +66 :raises KepURLError: If urllib provides an URLError +67 ''' +68 r = server._config_del(server.url + _create_url(log_group)) +69 if r.code == 200: return True +70 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
71def modify_log_group(server: server, DATA: dict, *, log_group: str = None, force: bool = False) -> bool: - 72 '''Modify a `"log group"` object and it's properties in Kepware's Datalogger. If a `"log group"` is not provided as an input, - 73 you need to identify the log group in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 74 assume that is the log group that is to be modified. - 75 - 76 :param server: instance of the `server` class - 77 :param DATA: Dict of the log group properties to be modified. - 78 :param log_group: *(optional)* name of log group to modify. Only needed if not existing in `"DATA"` - 79 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 80 - 81 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 82 - 83 :raises KepHTTPError: If urllib provides an HTTPError - 84 :raises KepURLError: If urllib provides an URLError - 85 ''' - 86 - 87 log_group_data = server._force_update_check(force, DATA) - 88 - 89 if log_group == None: - 90 try: - 91 r = server._config_update(server.url + _create_url(log_group_data['common.ALLTYPES_NAME']), log_group_data) - 92 if r.code == 200: return True - 93 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 94 except KeyError as err: - 95 err_msg = 'Error: No log group identified in DATA | Key Error: {}'.format(err) - 96 raise KepError(err_msg) - 97 else: - 98 r = server._config_update(server.url + _create_url(log_group), log_group_data) - 99 if r.code == 200: return True -100 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -463,19 +464,19 @@72def modify_log_group(server: server, DATA: dict, *, log_group: str = None, force: bool = False) -> bool: + 73 '''Modify a `"log group"` object and it's properties in Kepware's Datalogger. If a `"log group"` is not provided as an input, + 74 you need to identify the log group in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 75 assume that is the log group that is to be modified. + 76 + 77 :param server: instance of the `server` class + 78 :param DATA: Dict of the log group properties to be modified. + 79 :param log_group: *(optional)* name of log group to modify. Only needed if not existing in `"DATA"` + 80 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 81 + 82 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 83 + 84 :raises KepHTTPError: If urllib provides an HTTPError + 85 :raises KepURLError: If urllib provides an URLError + 86 ''' + 87 + 88 log_group_data = server._force_update_check(force, DATA) + 89 + 90 if log_group == None: + 91 try: + 92 r = server._config_update(server.url + _create_url(log_group_data['common.ALLTYPES_NAME']), log_group_data) + 93 if r.code == 200: return True + 94 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 95 except KeyError as err: + 96 err_msg = 'Error: No log group identified in DATA | Key Error: {}'.format(err) + 97 raise KepError(err_msg) + 98 else: + 99 r = server._config_update(server.url + _create_url(log_group), log_group_data) +100 if r.code == 200: return True +101 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
102def get_log_group(server: server, log_group: str) -> dict: -103 '''Returns the properties of the `"log group"` object. -104 -105 :param server: instance of the `server` class -106 :param log_group: name of log group to retrieve -107 -108 :return: Dict of properties for the log group requested -109 -110 :raises KepHTTPError: If urllib provides an HTTPError -111 :raises KepURLError: If urllib provides an URLError -112 ''' -113 r = server._config_get(server.url + _create_url(log_group)) -114 return r.payload +@@ -515,20 +516,20 @@103def get_log_group(server: server, log_group: str) -> dict: +104 '''Returns the properties of the `"log group"` object. +105 +106 :param server: instance of the `server` class +107 :param log_group: name of log group to retrieve +108 +109 :return: Dict of properties for the log group requested +110 +111 :raises KepHTTPError: If urllib provides an HTTPError +112 :raises KepURLError: If urllib provides an URLError +113 ''' +114 r = server._config_get(server.url + _create_url(log_group)) +115 return r.payloadRaises
116def get_all_log_groups(server: server, *, options: dict = None) -> list: -117 '''Returns the properties of all log group objects for Kepware's Datalogger. Returned object is JSON list. -118 -119 :param server: instance of the `server` class -120 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', -121 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -122 -123 :return: list of properties for all log groups requested -124 -125 :raises KepHTTPError: If urllib provides an HTTPError -126 :raises KepURLError: If urllib provides an URLError -127 ''' -128 r = server._config_get(f'{server.url}{_create_url()}', params= options) -129 return r.payload +@@ -569,19 +570,19 @@117def get_all_log_groups(server: server, *, options: dict = None) -> list: +118 '''Returns the properties of all log group objects for Kepware's Datalogger. Returned object is JSON list. +119 +120 :param server: instance of the `server` class +121 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', +122 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +123 +124 :return: list of properties for all log groups requested +125 +126 :raises KepHTTPError: If urllib provides an HTTPError +127 :raises KepURLError: If urllib provides an URLError +128 ''' +129 r = server._config_get(f'{server.url}{_create_url()}', params= options) +130 return r.payloadRaises
131def enable_log_group(server: server, log_group: str) -> bool: -132 '''Enable the `"log group"`. -133 -134 :param server: instance of the `server` class -135 :param log_group: name of log group to enable -136 -137 :return: True - If a "HTTP 200 - OK" is received from Kepware server -138 -139 :raises KepHTTPError: If urllib provides an HTTPError -140 :raises KepURLError: If urllib provides an URLError -141 ''' -142 DATA = {ENABLE_PROPERTY: True} -143 return modify_log_group(server, DATA, log_group= log_group) +@@ -621,19 +622,19 @@132def enable_log_group(server: server, log_group: str) -> bool: +133 '''Enable the `"log group"`. +134 +135 :param server: instance of the `server` class +136 :param log_group: name of log group to enable +137 +138 :return: True - If a "HTTP 200 - OK" is received from Kepware server +139 +140 :raises KepHTTPError: If urllib provides an HTTPError +141 :raises KepURLError: If urllib provides an URLError +142 ''' +143 DATA = {ENABLE_PROPERTY: True} +144 return modify_log_group(server, DATA, log_group= log_group)Raises
145def disable_log_group(server: server, log_group: str) -> bool: -146 '''Disable the log group. Returned object is JSON. -147 -148 :param server: instance of the `server` class -149 :param log_group: name of log group to enable -150 -151 :return: True - If a "HTTP 200 - OK" is received from Kepware server -152 -153 :raises KepHTTPError: If urllib provides an HTTPError -154 :raises KepURLError: If urllib provides an URLError -155 ''' -156 DATA = {ENABLE_PROPERTY: False} -157 return modify_log_group(server, DATA, log_group= log_group) +@@ -673,22 +674,22 @@146def disable_log_group(server: server, log_group: str) -> bool: +147 '''Disable the log group. Returned object is JSON. +148 +149 :param server: instance of the `server` class +150 :param log_group: name of log group to enable +151 +152 :return: True - If a "HTTP 200 - OK" is received from Kepware server +153 +154 :raises KepHTTPError: If urllib provides an HTTPError +155 :raises KepURLError: If urllib provides an URLError +156 ''' +157 DATA = {ENABLE_PROPERTY: False} +158 return modify_log_group(server, DATA, log_group= log_group)Raises
159def reset_column_mapping_service(server: server, log_group: str, job_ttl: int = None) -> KepServiceResponse: -160 '''Executes a ResetColumnMapping serivce call to the log group -161 -162 :param server: instance of the `server` class -163 :param log_group: name of log group to enable -164 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion. -165 -166 :return: `KepServiceResponse` instance with job information -167 -168 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned) -169 :raises KepURLError: If urllib provides an URLError -170 ''' -171 -172 url = server.url + _create_url(log_group) + SERVICES_ROOT + '/ResetColumnMapping' -173 job = server._kep_service_execute(url, None, job_ttl) -174 return job +diff --git a/docs/kepconfig/datalogger/log_items.html b/docs/kepconfig/datalogger/log_items.html index bd5b2bd..bbaf99e 100644 --- a/docs/kepconfig/datalogger/log_items.html +++ b/docs/kepconfig/datalogger/log_items.html @@ -82,126 +82,127 @@160def reset_column_mapping_service(server: server, log_group: str, job_ttl: int = None) -> KepServiceResponse: +161 '''Executes a ResetColumnMapping serivce call to the log group +162 +163 :param server: instance of the `server` class +164 :param log_group: name of log group to enable +165 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion. +166 +167 :return: `KepServiceResponse` instance with job information +168 +169 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned) +170 :raises KepURLError: If urllib provides an URLError +171 ''' +172 +173 url = server.url + _create_url(log_group) + SERVICES_ROOT + '/ResetColumnMapping' +174 job = server._kep_service_execute(url, None, job_ttl) +175 return job11from . import log_group as Log_Group 12from ..error import KepError, KepHTTPError 13from ..connection import server - 14 - 15LOG_ITEMS_ROOT = '/log_items' - 16 - 17def _create_url(log_item = None): - 18 '''Creates url object for the "log_item" branch of Kepware's project tree. Used - 19 to build a part of Kepware Configuration API URL structure - 20 - 21 Returns the log_item specific url when a value is passed as the log_item name. - 22 ''' - 23 - 24 if log_item == None: - 25 return '{}'.format(LOG_ITEMS_ROOT) - 26 else: - 27 return '{}/{}'.format(LOG_ITEMS_ROOT, log_item) - 28 + 14from ..utils import _url_parse_object + 15 + 16LOG_ITEMS_ROOT = '/log_items' + 17 + 18def _create_url(log_item = None): + 19 '''Creates url object for the "log_item" branch of Kepware's project tree. Used + 20 to build a part of Kepware Configuration API URL structure + 21 + 22 Returns the log_item specific url when a value is passed as the log_item name. + 23 ''' + 24 + 25 if log_item == None: + 26 return '{}'.format(LOG_ITEMS_ROOT) + 27 else: + 28 return '{}/{}'.format(LOG_ITEMS_ROOT, _url_parse_object(log_item)) 29 - 30def add_log_item(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: - 31 '''Add a `"log item"` or multiple `"log item"` objects to a log group in Kepware's Datalogger. It can - 32 be used to pass a list of log items to be added all at once. - 33 - 34 :param server: instance of the `server` class - 35 :param log_group: name of log group that the log items will be added - 36 :param DATA: Dict or a list of the log items to add through Kepware Configuration API - 37 - 38 :return: True - If a "HTTP 201 - Created" is received from Kepware server - 39 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all - 40 log items added that failed. - 41 - 42 :raises KepHTTPError: If urllib provides an HTTPError - 43 :raises KepURLError: If urllib provides an URLError - 44 ''' - 45 - 46 r = server._config_add(server.url + Log_Group._create_url(log_group) + _create_url(), DATA) - 47 if r.code == 201: return True - 48 elif r.code == 207: - 49 errors = [] - 50 for item in r.payload: - 51 if item['code'] != 201: - 52 errors.append(item) - 53 return errors - 54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 55 - 56def del_log_item(server: server, log_group: str, log_item: str) -> bool: - 57 '''Delete a `"log item"` object of a log group in Kepware's Datalogger. - 58 - 59 :param server: instance of the `server` class - 60 :param log_group: name of log group that log item exists - 61 :param log_item: name of log item to delete - 62 - 63 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 64 - 65 :raises KepHTTPError: If urllib provides an HTTPError - 66 :raises KepURLError: If urllib provides an URLError - 67 ''' - 68 r = server._config_del(server.url + Log_Group._create_url(log_group) + _create_url(log_item)) - 69 if r.code == 200: return True - 70 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 71 - 72def modify_log_item(server: server, log_group: str, DATA: dict, *, log_item: str = None, force: bool = False) -> bool: - 73 '''Modify a `"log_item"` object and it's properties in Kepware. If a `"log_item"` is not provided as an input, - 74 you need to identify the log_item in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 75 assume that is the log_item that is to be modified. - 76 - 77 :param server: instance of the `server` class - 78 :param log_group: name of log group that log item exists - 79 :param DATA: Dict of the log item properties to be modified. - 80 :param log_item: *(optional)* name of log item to modify. Only needed if not existing in `"DATA"` - 81 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 82 - 83 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 84 - 85 :raises KepHTTPError: If urllib provides an HTTPError - 86 :raises KepURLError: If urllib provides an URLError - 87 ''' - 88 - 89 log_item_data = server._force_update_check(force, DATA) - 90 - 91 if log_item == None: - 92 try: - 93 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(log_item_data['common.ALLTYPES_NAME']), log_item_data) - 94 if r.code == 200: return True - 95 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 96 except KeyError as err: - 97 err_msg ='Error: No log item identified in DATA | Key Error: {}'.format(err) - 98 raise KepError(err_msg) - 99 else: -100 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(log_item), log_item_data) -101 if r.code == 200: return True -102 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -103 -104def get_log_item(server, log_group, log_item) -> dict: -105 '''Returns the properties of the `"log item"` object. -106 -107 :param server: instance of the `server` class -108 :param log_group: name of log group that log item exists -109 :param log_item: name of log item to retrieve -110 -111 :return: Dict of properties for the log group requested -112 -113 :raises KepHTTPError: If urllib provides an HTTPError -114 :raises KepURLError: If urllib provides an URLError -115 ''' -116 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(log_item)) -117 return r.payload -118 -119def get_all_log_items(server: server, log_group: str, *, options: dict = None) -> list: -120 '''Returns the properties of all `"log item"` objects for a log group. -121 -122 :param server: instance of the `server` class -123 :param log_group: name of log group that log item exists -124 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', -125 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -126 -127 :return: list of properties for all log items in the log group requested -128 -129 :raises KepHTTPError: If urllib provides an HTTPError -130 :raises KepURLError: If urllib provides an URLError -131 ''' -132 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) -133 return r.payload + 30 + 31def add_log_item(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: + 32 '''Add a `"log item"` or multiple `"log item"` objects to a log group in Kepware's Datalogger. It can + 33 be used to pass a list of log items to be added all at once. + 34 + 35 :param server: instance of the `server` class + 36 :param log_group: name of log group that the log items will be added + 37 :param DATA: Dict or a list of the log items to add through Kepware Configuration API + 38 + 39 :return: True - If a "HTTP 201 - Created" is received from Kepware server + 40 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all + 41 log items added that failed. + 42 + 43 :raises KepHTTPError: If urllib provides an HTTPError + 44 :raises KepURLError: If urllib provides an URLError + 45 ''' + 46 + 47 r = server._config_add(server.url + Log_Group._create_url(log_group) + _create_url(), DATA) + 48 if r.code == 201: return True + 49 elif r.code == 207: + 50 errors = [] + 51 for item in r.payload: + 52 if item['code'] != 201: + 53 errors.append(item) + 54 return errors + 55 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 56 + 57def del_log_item(server: server, log_group: str, log_item: str) -> bool: + 58 '''Delete a `"log item"` object of a log group in Kepware's Datalogger. + 59 + 60 :param server: instance of the `server` class + 61 :param log_group: name of log group that log item exists + 62 :param log_item: name of log item to delete + 63 + 64 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 65 + 66 :raises KepHTTPError: If urllib provides an HTTPError + 67 :raises KepURLError: If urllib provides an URLError + 68 ''' + 69 r = server._config_del(server.url + Log_Group._create_url(log_group) + _create_url(log_item)) + 70 if r.code == 200: return True + 71 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 72 + 73def modify_log_item(server: server, log_group: str, DATA: dict, *, log_item: str = None, force: bool = False) -> bool: + 74 '''Modify a `"log_item"` object and it's properties in Kepware. If a `"log_item"` is not provided as an input, + 75 you need to identify the log_item in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 76 assume that is the log_item that is to be modified. + 77 + 78 :param server: instance of the `server` class + 79 :param log_group: name of log group that log item exists + 80 :param DATA: Dict of the log item properties to be modified. + 81 :param log_item: *(optional)* name of log item to modify. Only needed if not existing in `"DATA"` + 82 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 83 + 84 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 85 + 86 :raises KepHTTPError: If urllib provides an HTTPError + 87 :raises KepURLError: If urllib provides an URLError + 88 ''' + 89 + 90 log_item_data = server._force_update_check(force, DATA) + 91 + 92 if log_item == None: + 93 try: + 94 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(log_item_data['common.ALLTYPES_NAME']), log_item_data) + 95 if r.code == 200: return True + 96 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 97 except KeyError as err: + 98 err_msg ='Error: No log item identified in DATA | Key Error: {}'.format(err) + 99 raise KepError(err_msg) +100 else: +101 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(log_item), log_item_data) +102 if r.code == 200: return True +103 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +104 +105def get_log_item(server, log_group, log_item) -> dict: +106 '''Returns the properties of the `"log item"` object. +107 +108 :param server: instance of the `server` class +109 :param log_group: name of log group that log item exists +110 :param log_item: name of log item to retrieve +111 +112 :return: Dict of properties for the log group requested +113 +114 :raises KepHTTPError: If urllib provides an HTTPError +115 :raises KepURLError: If urllib provides an URLError +116 ''' +117 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(log_item)) +118 return r.payload +119 +120def get_all_log_items(server: server, log_group: str, *, options: dict = None) -> list: +121 '''Returns the properties of all `"log item"` objects for a log group. +122 +123 :param server: instance of the `server` class +124 :param log_group: name of log group that log item exists +125 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', +126 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +127 +128 :return: list of properties for all log items in the log group requested +129 +130 :raises KepHTTPError: If urllib provides an HTTPError +131 :raises KepURLError: If urllib provides an URLError +132 ''' +133 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) +134 return r.payload
31def add_log_item(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: -32 '''Add a `"log item"` or multiple `"log item"` objects to a log group in Kepware's Datalogger. It can -33 be used to pass a list of log items to be added all at once. -34 -35 :param server: instance of the `server` class -36 :param log_group: name of log group that the log items will be added -37 :param DATA: Dict or a list of the log items to add through Kepware Configuration API -38 -39 :return: True - If a "HTTP 201 - Created" is received from Kepware server -40 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -41 log items added that failed. -42 -43 :raises KepHTTPError: If urllib provides an HTTPError -44 :raises KepURLError: If urllib provides an URLError -45 ''' -46 -47 r = server._config_add(server.url + Log_Group._create_url(log_group) + _create_url(), DATA) -48 if r.code == 201: return True -49 elif r.code == 207: -50 errors = [] -51 for item in r.payload: -52 if item['code'] != 201: -53 errors.append(item) -54 return errors -55 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -290,21 +291,21 @@32def add_log_item(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: +33 '''Add a `"log item"` or multiple `"log item"` objects to a log group in Kepware's Datalogger. It can +34 be used to pass a list of log items to be added all at once. +35 +36 :param server: instance of the `server` class +37 :param log_group: name of log group that the log items will be added +38 :param DATA: Dict or a list of the log items to add through Kepware Configuration API +39 +40 :return: True - If a "HTTP 201 - Created" is received from Kepware server +41 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all +42 log items added that failed. +43 +44 :raises KepHTTPError: If urllib provides an HTTPError +45 :raises KepURLError: If urllib provides an URLError +46 ''' +47 +48 r = server._config_add(server.url + Log_Group._create_url(log_group) + _create_url(), DATA) +49 if r.code == 201: return True +50 elif r.code == 207: +51 errors = [] +52 for item in r.payload: +53 if item['code'] != 201: +54 errors.append(item) +55 return errors +56 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
57def del_log_item(server: server, log_group: str, log_item: str) -> bool: -58 '''Delete a `"log item"` object of a log group in Kepware's Datalogger. -59 -60 :param server: instance of the `server` class -61 :param log_group: name of log group that log item exists -62 :param log_item: name of log item to delete -63 -64 :return: True - If a "HTTP 200 - OK" is received from Kepware server -65 -66 :raises KepHTTPError: If urllib provides an HTTPError -67 :raises KepURLError: If urllib provides an URLError -68 ''' -69 r = server._config_del(server.url + Log_Group._create_url(log_group) + _create_url(log_item)) -70 if r.code == 200: return True -71 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -345,37 +346,37 @@58def del_log_item(server: server, log_group: str, log_item: str) -> bool: +59 '''Delete a `"log item"` object of a log group in Kepware's Datalogger. +60 +61 :param server: instance of the `server` class +62 :param log_group: name of log group that log item exists +63 :param log_item: name of log item to delete +64 +65 :return: True - If a "HTTP 200 - OK" is received from Kepware server +66 +67 :raises KepHTTPError: If urllib provides an HTTPError +68 :raises KepURLError: If urllib provides an URLError +69 ''' +70 r = server._config_del(server.url + Log_Group._create_url(log_group) + _create_url(log_item)) +71 if r.code == 200: return True +72 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
73def modify_log_item(server: server, log_group: str, DATA: dict, *, log_item: str = None, force: bool = False) -> bool: - 74 '''Modify a `"log_item"` object and it's properties in Kepware. If a `"log_item"` is not provided as an input, - 75 you need to identify the log_item in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 76 assume that is the log_item that is to be modified. - 77 - 78 :param server: instance of the `server` class - 79 :param log_group: name of log group that log item exists - 80 :param DATA: Dict of the log item properties to be modified. - 81 :param log_item: *(optional)* name of log item to modify. Only needed if not existing in `"DATA"` - 82 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 83 - 84 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 85 - 86 :raises KepHTTPError: If urllib provides an HTTPError - 87 :raises KepURLError: If urllib provides an URLError - 88 ''' - 89 - 90 log_item_data = server._force_update_check(force, DATA) - 91 - 92 if log_item == None: - 93 try: - 94 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(log_item_data['common.ALLTYPES_NAME']), log_item_data) - 95 if r.code == 200: return True - 96 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 97 except KeyError as err: - 98 err_msg ='Error: No log item identified in DATA | Key Error: {}'.format(err) - 99 raise KepError(err_msg) -100 else: -101 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(log_item), log_item_data) -102 if r.code == 200: return True -103 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -420,20 +421,20 @@74def modify_log_item(server: server, log_group: str, DATA: dict, *, log_item: str = None, force: bool = False) -> bool: + 75 '''Modify a `"log_item"` object and it's properties in Kepware. If a `"log_item"` is not provided as an input, + 76 you need to identify the log_item in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 77 assume that is the log_item that is to be modified. + 78 + 79 :param server: instance of the `server` class + 80 :param log_group: name of log group that log item exists + 81 :param DATA: Dict of the log item properties to be modified. + 82 :param log_item: *(optional)* name of log item to modify. Only needed if not existing in `"DATA"` + 83 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 84 + 85 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 86 + 87 :raises KepHTTPError: If urllib provides an HTTPError + 88 :raises KepURLError: If urllib provides an URLError + 89 ''' + 90 + 91 log_item_data = server._force_update_check(force, DATA) + 92 + 93 if log_item == None: + 94 try: + 95 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(log_item_data['common.ALLTYPES_NAME']), log_item_data) + 96 if r.code == 200: return True + 97 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 98 except KeyError as err: + 99 err_msg ='Error: No log item identified in DATA | Key Error: {}'.format(err) +100 raise KepError(err_msg) +101 else: +102 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(log_item), log_item_data) +103 if r.code == 200: return True +104 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
105def get_log_item(server, log_group, log_item) -> dict: -106 '''Returns the properties of the `"log item"` object. -107 -108 :param server: instance of the `server` class -109 :param log_group: name of log group that log item exists -110 :param log_item: name of log item to retrieve -111 -112 :return: Dict of properties for the log group requested -113 -114 :raises KepHTTPError: If urllib provides an HTTPError -115 :raises KepURLError: If urllib provides an URLError -116 ''' -117 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(log_item)) -118 return r.payload +@@ -474,21 +475,21 @@106def get_log_item(server, log_group, log_item) -> dict: +107 '''Returns the properties of the `"log item"` object. +108 +109 :param server: instance of the `server` class +110 :param log_group: name of log group that log item exists +111 :param log_item: name of log item to retrieve +112 +113 :return: Dict of properties for the log group requested +114 +115 :raises KepHTTPError: If urllib provides an HTTPError +116 :raises KepURLError: If urllib provides an URLError +117 ''' +118 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(log_item)) +119 return r.payloadRaises
120def get_all_log_items(server: server, log_group: str, *, options: dict = None) -> list: -121 '''Returns the properties of all `"log item"` objects for a log group. -122 -123 :param server: instance of the `server` class -124 :param log_group: name of log group that log item exists -125 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', -126 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -127 -128 :return: list of properties for all log items in the log group requested -129 -130 :raises KepHTTPError: If urllib provides an HTTPError -131 :raises KepURLError: If urllib provides an URLError -132 ''' -133 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) -134 return r.payload +diff --git a/docs/kepconfig/datalogger/mapping.html b/docs/kepconfig/datalogger/mapping.html index 1bee0c8..7e891d8 100644 --- a/docs/kepconfig/datalogger/mapping.html +++ b/docs/kepconfig/datalogger/mapping.html @@ -76,83 +76,84 @@121def get_all_log_items(server: server, log_group: str, *, options: dict = None) -> list: +122 '''Returns the properties of all `"log item"` objects for a log group. +123 +124 :param server: instance of the `server` class +125 :param log_group: name of log group that log item exists +126 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', +127 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +128 +129 :return: list of properties for all log items in the log group requested +130 +131 :raises KepHTTPError: If urllib provides an HTTPError +132 :raises KepURLError: If urllib provides an URLError +133 ''' +134 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) +135 return r.payload11from . import log_group as Log_Group 12from ..error import KepError, KepHTTPError 13from ..connection import server -14 -15MAPPING_ROOT = '/column_mappings' -16 -17def _create_url(mapping = None): -18 '''Creates url object for the "column_mappings" branch of Kepware's project tree. Used -19 to build a part of Kepware Configuration API URL structure -20 -21 Returns the mapping specific url when a value is passed as the column_mapping name. -22 ''' -23 -24 if mapping == None: -25 return '{}'.format(MAPPING_ROOT) -26 else: -27 return '{}/{}'.format(MAPPING_ROOT, mapping) -28 -29def modify_mapping(server: server, log_group: str, DATA: dict, *, mapping: str = None, force: bool = False) -> bool: -30 '''Modify a column `"mapping"` object and it's properties in Kepware. If a `"mapping"` is not provided as an input, -31 you need to identify the column mapping in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will -32 assume that is the column mapping that is to be modified. -33 -34 :param server: instance of the `server` class -35 :param log_group: name of log group for the mapping -36 :param DATA: Dict of the mapping properties to be modified. -37 :param mapping: *(optional)* column mapping to modify in the log group. Only needed if not existing in `"DATA"` -38 :param force: *(optional)* if True, will force the configuration update to the Kepware server -39 -40 :return: True - If a "HTTP 200 - OK" is received from Kepware server -41 -42 :raises KepHTTPError: If urllib provides an HTTPError -43 :raises KepURLError: If urllib provides an URLError -44 ''' -45 -46 mapping_data = server._force_update_check(force, DATA) -47 -48 if mapping == None: -49 try: -50 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(mapping_data['common.ALLTYPES_NAME']), mapping_data) -51 if r.code == 200: return True -52 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -53 except KeyError as err: -54 err_msg = 'Error: No column mapping identified in DATA | Key Error: {}'.format(err) -55 raise KepError(err_msg) -56 else: -57 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(mapping), mapping_data) -58 if r.code == 200: return True -59 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -60 -61def get_mapping(server: server, log_group: str, mapping: str) -> dict: -62 '''Returns the properties of the `"mapping"` object. -63 -64 :param server: instance of the `server` class -65 :param log_group: name of log group for the mapping -66 :param mapping: name of column mapping to retrieve properties -67 -68 :return: Dict of properties for the mapping object requested -69 -70 :raises KepHTTPError: If urllib provides an HTTPError -71 :raises KepURLError: If urllib provides an URLError -72 ''' -73 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(mapping)) -74 return r.payload -75 -76def get_all_mappings(server: server, log_group: str, *, options: dict = None) -> list: -77 '''Returns the properties of all column `"mapping"` objects for a log group. -78 -79 :param server: instance of the `server` class -80 :param log_group: name of log group for the mapping -81 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of mapping items. Options are 'filter', -82 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -83 -84 :return: list of properties for all mapping items in the log group requested -85 -86 :raises KepHTTPError: If urllib provides an HTTPError -87 :raises KepURLError: If urllib provides an URLError -88 ''' -89 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) -90 return r.payload +14from ..utils import _url_parse_object +15 +16MAPPING_ROOT = '/column_mappings' +17 +18def _create_url(mapping = None): +19 '''Creates url object for the "column_mappings" branch of Kepware's project tree. Used +20 to build a part of Kepware Configuration API URL structure +21 +22 Returns the mapping specific url when a value is passed as the column_mapping name. +23 ''' +24 +25 if mapping == None: +26 return '{}'.format(MAPPING_ROOT) +27 else: +28 return '{}/{}'.format(MAPPING_ROOT, _url_parse_object(mapping)) +29 +30def modify_mapping(server: server, log_group: str, DATA: dict, *, mapping: str = None, force: bool = False) -> bool: +31 '''Modify a column `"mapping"` object and it's properties in Kepware. If a `"mapping"` is not provided as an input, +32 you need to identify the column mapping in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will +33 assume that is the column mapping that is to be modified. +34 +35 :param server: instance of the `server` class +36 :param log_group: name of log group for the mapping +37 :param DATA: Dict of the mapping properties to be modified. +38 :param mapping: *(optional)* column mapping to modify in the log group. Only needed if not existing in `"DATA"` +39 :param force: *(optional)* if True, will force the configuration update to the Kepware server +40 +41 :return: True - If a "HTTP 200 - OK" is received from Kepware server +42 +43 :raises KepHTTPError: If urllib provides an HTTPError +44 :raises KepURLError: If urllib provides an URLError +45 ''' +46 +47 mapping_data = server._force_update_check(force, DATA) +48 +49 if mapping == None: +50 try: +51 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(mapping_data['common.ALLTYPES_NAME']), mapping_data) +52 if r.code == 200: return True +53 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +54 except KeyError as err: +55 err_msg = 'Error: No column mapping identified in DATA | Key Error: {}'.format(err) +56 raise KepError(err_msg) +57 else: +58 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(mapping), mapping_data) +59 if r.code == 200: return True +60 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +61 +62def get_mapping(server: server, log_group: str, mapping: str) -> dict: +63 '''Returns the properties of the `"mapping"` object. +64 +65 :param server: instance of the `server` class +66 :param log_group: name of log group for the mapping +67 :param mapping: name of column mapping to retrieve properties +68 +69 :return: Dict of properties for the mapping object requested +70 +71 :raises KepHTTPError: If urllib provides an HTTPError +72 :raises KepURLError: If urllib provides an URLError +73 ''' +74 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(mapping)) +75 return r.payload +76 +77def get_all_mappings(server: server, log_group: str, *, options: dict = None) -> list: +78 '''Returns the properties of all column `"mapping"` objects for a log group. +79 +80 :param server: instance of the `server` class +81 :param log_group: name of log group for the mapping +82 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of mapping items. Options are 'filter', +83 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +84 +85 :return: list of properties for all mapping items in the log group requested +86 +87 :raises KepHTTPError: If urllib provides an HTTPError +88 :raises KepURLError: If urllib provides an URLError +89 ''' +90 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) +91 return r.payload
30def modify_mapping(server: server, log_group: str, DATA: dict, *, mapping: str = None, force: bool = False) -> bool: -31 '''Modify a column `"mapping"` object and it's properties in Kepware. If a `"mapping"` is not provided as an input, -32 you need to identify the column mapping in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will -33 assume that is the column mapping that is to be modified. -34 -35 :param server: instance of the `server` class -36 :param log_group: name of log group for the mapping -37 :param DATA: Dict of the mapping properties to be modified. -38 :param mapping: *(optional)* column mapping to modify in the log group. Only needed if not existing in `"DATA"` -39 :param force: *(optional)* if True, will force the configuration update to the Kepware server -40 -41 :return: True - If a "HTTP 200 - OK" is received from Kepware server -42 -43 :raises KepHTTPError: If urllib provides an HTTPError -44 :raises KepURLError: If urllib provides an URLError -45 ''' -46 -47 mapping_data = server._force_update_check(force, DATA) -48 -49 if mapping == None: -50 try: -51 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(mapping_data['common.ALLTYPES_NAME']), mapping_data) -52 if r.code == 200: return True -53 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -54 except KeyError as err: -55 err_msg = 'Error: No column mapping identified in DATA | Key Error: {}'.format(err) -56 raise KepError(err_msg) -57 else: -58 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(mapping), mapping_data) -59 if r.code == 200: return True -60 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -243,20 +244,20 @@31def modify_mapping(server: server, log_group: str, DATA: dict, *, mapping: str = None, force: bool = False) -> bool: +32 '''Modify a column `"mapping"` object and it's properties in Kepware. If a `"mapping"` is not provided as an input, +33 you need to identify the column mapping in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will +34 assume that is the column mapping that is to be modified. +35 +36 :param server: instance of the `server` class +37 :param log_group: name of log group for the mapping +38 :param DATA: Dict of the mapping properties to be modified. +39 :param mapping: *(optional)* column mapping to modify in the log group. Only needed if not existing in `"DATA"` +40 :param force: *(optional)* if True, will force the configuration update to the Kepware server +41 +42 :return: True - If a "HTTP 200 - OK" is received from Kepware server +43 +44 :raises KepHTTPError: If urllib provides an HTTPError +45 :raises KepURLError: If urllib provides an URLError +46 ''' +47 +48 mapping_data = server._force_update_check(force, DATA) +49 +50 if mapping == None: +51 try: +52 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(mapping_data['common.ALLTYPES_NAME']), mapping_data) +53 if r.code == 200: return True +54 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +55 except KeyError as err: +56 err_msg = 'Error: No column mapping identified in DATA | Key Error: {}'.format(err) +57 raise KepError(err_msg) +58 else: +59 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(mapping), mapping_data) +60 if r.code == 200: return True +61 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
62def get_mapping(server: server, log_group: str, mapping: str) -> dict: -63 '''Returns the properties of the `"mapping"` object. -64 -65 :param server: instance of the `server` class -66 :param log_group: name of log group for the mapping -67 :param mapping: name of column mapping to retrieve properties -68 -69 :return: Dict of properties for the mapping object requested -70 -71 :raises KepHTTPError: If urllib provides an HTTPError -72 :raises KepURLError: If urllib provides an URLError -73 ''' -74 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(mapping)) -75 return r.payload +@@ -297,21 +298,21 @@63def get_mapping(server: server, log_group: str, mapping: str) -> dict: +64 '''Returns the properties of the `"mapping"` object. +65 +66 :param server: instance of the `server` class +67 :param log_group: name of log group for the mapping +68 :param mapping: name of column mapping to retrieve properties +69 +70 :return: Dict of properties for the mapping object requested +71 +72 :raises KepHTTPError: If urllib provides an HTTPError +73 :raises KepURLError: If urllib provides an URLError +74 ''' +75 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(mapping)) +76 return r.payloadRaises
77def get_all_mappings(server: server, log_group: str, *, options: dict = None) -> list: -78 '''Returns the properties of all column `"mapping"` objects for a log group. -79 -80 :param server: instance of the `server` class -81 :param log_group: name of log group for the mapping -82 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of mapping items. Options are 'filter', -83 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -84 -85 :return: list of properties for all mapping items in the log group requested -86 -87 :raises KepHTTPError: If urllib provides an HTTPError -88 :raises KepURLError: If urllib provides an URLError -89 ''' -90 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) -91 return r.payload +diff --git a/docs/kepconfig/datalogger/triggers.html b/docs/kepconfig/datalogger/triggers.html index a4c001f..2c7c3a7 100644 --- a/docs/kepconfig/datalogger/triggers.html +++ b/docs/kepconfig/datalogger/triggers.html @@ -83,133 +83,134 @@78def get_all_mappings(server: server, log_group: str, *, options: dict = None) -> list: +79 '''Returns the properties of all column `"mapping"` objects for a log group. +80 +81 :param server: instance of the `server` class +82 :param log_group: name of log group for the mapping +83 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of mapping items. Options are 'filter', +84 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +85 +86 :return: list of properties for all mapping items in the log group requested +87 +88 :raises KepHTTPError: If urllib provides an HTTPError +89 :raises KepURLError: If urllib provides an URLError +90 ''' +91 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) +92 return r.payload12from . import log_group as Log_Group 13from ..error import KepError, KepHTTPError 14from ..connection import server - 15 - 16TRIGGERS_ROOT = '/triggers' - 17 - 18def _create_url(trigger = None): - 19 '''Creates url object for the "trigger" branch of Kepware's project tree. Used - 20 to build a part of Kepware Configuration API URL structure - 21 - 22 Returns the trigger specific url when a value is passed as the trigger name. - 23 ''' - 24 - 25 if trigger == None: - 26 return '{}'.format(TRIGGERS_ROOT) - 27 else: - 28 return '{}/{}'.format(TRIGGERS_ROOT, trigger) - 29 + 15from ..utils import _url_parse_object + 16 + 17TRIGGERS_ROOT = '/triggers' + 18 + 19def _create_url(trigger = None): + 20 '''Creates url object for the "trigger" branch of Kepware's project tree. Used + 21 to build a part of Kepware Configuration API URL structure + 22 + 23 Returns the trigger specific url when a value is passed as the trigger name. + 24 ''' + 25 + 26 if trigger == None: + 27 return '{}'.format(TRIGGERS_ROOT) + 28 else: + 29 return '{}/{}'.format(TRIGGERS_ROOT, _url_parse_object(trigger)) 30 - 31def add_trigger(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: - 32 '''Add a `"trigger"` or multiple `"trigger"` objects to a log group in Kepware's Datalogger. It can - 33 be used to pass a list of triggers to be added all at once. - 34 - 35 :param server: instance of the `server` class - 36 :param log_group: name of log group for the trigger items - 37 :param DATA: Dict or a list of the trigger items to add through Kepware Configuration API - 38 - 39 :return: True - If a "HTTP 201 - Created" is received from Kepware server - 40 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all - 41 triggers added that failed. - 42 - 43 :raises KepHTTPError: If urllib provides an HTTPError - 44 :raises KepURLError: If urllib provides an URLError - 45 ''' - 46 - 47 r = server._config_add(server.url + Log_Group._create_url(log_group) + _create_url(), DATA) - 48 if r.code == 201: return True - 49 elif r.code == 207: - 50 errors = [] - 51 for item in r.payload: - 52 if item['code'] != 201: - 53 errors.append(item) - 54 return errors - 55 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 56 - 57def del_trigger(server: server, log_group: str, trigger: str) -> bool: - 58 '''Delete a `"trigger"` object of a log group in Kepware's Datalogger. - 59 - 60 :param server: instance of the `server` class - 61 :param log_group: name of log group for the trigger items - 62 :param trigger: name of trigger to delete - 63 - 64 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 65 - 66 :raises KepHTTPError: If urllib provides an HTTPError - 67 :raises KepURLError: If urllib provides an URLError - 68 ''' - 69 r = server._config_del(server.url + Log_Group._create_url(log_group) + _create_url(trigger)) - 70 if r.code == 200: return True - 71 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 72 - 73def modify_trigger(server: server, log_group: str, DATA: dict, *, trigger: str = None, force: bool = False) -> bool: - 74 '''Modify a `"trigger"` object and it's properties in Kepware. If a `"trigger"` is not provided as an input, - 75 you need to identify the trigger in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 76 assume that is the trigger that is to be modified. - 77 - 78 :param server: instance of the `server` class - 79 :param log_group: name of log group for the trigger items - 80 :param DATA: Dict of the trigger properties to be modified. - 81 :param trigger: *(optional)* name of trigger to modify in the log group. Only needed if not existing in `"DATA"` - 82 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 83 - 84 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 85 - 86 :raises KepHTTPError: If urllib provides an HTTPError - 87 :raises KepURLError: If urllib provides an URLError - 88 ''' - 89 - 90 trigger_data = server._force_update_check(force, DATA) - 91 - 92 if trigger == None: - 93 try: - 94 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(trigger_data['common.ALLTYPES_NAME']), trigger_data) - 95 if r.code == 200: return True - 96 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 97 except KeyError as err: - 98 err_msg = 'Error: No trigger identified in DATA | Key Error: {}'.format(err) - 99 raise KepError(err_msg) -100 # except: -101 # return 'Error: Error with {}'.format(inspect.currentframe().f_code.co_name) -102 else: -103 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(trigger), trigger_data) -104 if r.code == 200: return True -105 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -106 -107def get_trigger(server, log_group, trigger) -> dict: -108 '''Returns the properties of the `"trigger"` object. -109 -110 :param server: instance of the `server` class -111 :param log_group: name of log group for the trigger items -112 :param trigger: name of trigger to retrieve -113 -114 :return: Dict of properties for the trigger requested -115 -116 :raises KepHTTPError: If urllib provides an HTTPError -117 :raises KepURLError: If urllib provides an URLError -118 ''' -119 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(trigger)) -120 return r.payload -121 -122def get_all_triggers(server: server, log_group: str, *, options: dict = None) -> list: -123 '''Returns the properties of all `"trigger"` objects for a log group. -124 -125 :param server: instance of the `server` class -126 :param log_group: name of log group for the trigger items -127 -128 :return: Dict of properties for the trigger requested -129 -130 :raises KepHTTPError: If urllib provides an HTTPError -131 :raises KepURLError: If urllib provides an URLError -132 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of triggers. Options are 'filter', -133 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -134 -135 :return: list of properties for all triggers in the log group requested -136 -137 :raises KepHTTPError: If urllib provides an HTTPError -138 :raises KepURLError: If urllib provides an URLError -139 ''' -140 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) -141 return r.payload + 31 + 32def add_trigger(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: + 33 '''Add a `"trigger"` or multiple `"trigger"` objects to a log group in Kepware's Datalogger. It can + 34 be used to pass a list of triggers to be added all at once. + 35 + 36 :param server: instance of the `server` class + 37 :param log_group: name of log group for the trigger items + 38 :param DATA: Dict or a list of the trigger items to add through Kepware Configuration API + 39 + 40 :return: True - If a "HTTP 201 - Created" is received from Kepware server + 41 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all + 42 triggers added that failed. + 43 + 44 :raises KepHTTPError: If urllib provides an HTTPError + 45 :raises KepURLError: If urllib provides an URLError + 46 ''' + 47 + 48 r = server._config_add(server.url + Log_Group._create_url(log_group) + _create_url(), DATA) + 49 if r.code == 201: return True + 50 elif r.code == 207: + 51 errors = [] + 52 for item in r.payload: + 53 if item['code'] != 201: + 54 errors.append(item) + 55 return errors + 56 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 57 + 58def del_trigger(server: server, log_group: str, trigger: str) -> bool: + 59 '''Delete a `"trigger"` object of a log group in Kepware's Datalogger. + 60 + 61 :param server: instance of the `server` class + 62 :param log_group: name of log group for the trigger items + 63 :param trigger: name of trigger to delete + 64 + 65 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 66 + 67 :raises KepHTTPError: If urllib provides an HTTPError + 68 :raises KepURLError: If urllib provides an URLError + 69 ''' + 70 r = server._config_del(server.url + Log_Group._create_url(log_group) + _create_url(trigger)) + 71 if r.code == 200: return True + 72 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 73 + 74def modify_trigger(server: server, log_group: str, DATA: dict, *, trigger: str = None, force: bool = False) -> bool: + 75 '''Modify a `"trigger"` object and it's properties in Kepware. If a `"trigger"` is not provided as an input, + 76 you need to identify the trigger in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 77 assume that is the trigger that is to be modified. + 78 + 79 :param server: instance of the `server` class + 80 :param log_group: name of log group for the trigger items + 81 :param DATA: Dict of the trigger properties to be modified. + 82 :param trigger: *(optional)* name of trigger to modify in the log group. Only needed if not existing in `"DATA"` + 83 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 84 + 85 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 86 + 87 :raises KepHTTPError: If urllib provides an HTTPError + 88 :raises KepURLError: If urllib provides an URLError + 89 ''' + 90 + 91 trigger_data = server._force_update_check(force, DATA) + 92 + 93 if trigger == None: + 94 try: + 95 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(trigger_data['common.ALLTYPES_NAME']), trigger_data) + 96 if r.code == 200: return True + 97 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 98 except KeyError as err: + 99 err_msg = 'Error: No trigger identified in DATA | Key Error: {}'.format(err) +100 raise KepError(err_msg) +101 # except: +102 # return 'Error: Error with {}'.format(inspect.currentframe().f_code.co_name) +103 else: +104 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(trigger), trigger_data) +105 if r.code == 200: return True +106 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +107 +108def get_trigger(server, log_group, trigger) -> dict: +109 '''Returns the properties of the `"trigger"` object. +110 +111 :param server: instance of the `server` class +112 :param log_group: name of log group for the trigger items +113 :param trigger: name of trigger to retrieve +114 +115 :return: Dict of properties for the trigger requested +116 +117 :raises KepHTTPError: If urllib provides an HTTPError +118 :raises KepURLError: If urllib provides an URLError +119 ''' +120 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(trigger)) +121 return r.payload +122 +123def get_all_triggers(server: server, log_group: str, *, options: dict = None) -> list: +124 '''Returns the properties of all `"trigger"` objects for a log group. +125 +126 :param server: instance of the `server` class +127 :param log_group: name of log group for the trigger items +128 +129 :return: Dict of properties for the trigger requested +130 +131 :raises KepHTTPError: If urllib provides an HTTPError +132 :raises KepURLError: If urllib provides an URLError +133 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of triggers. Options are 'filter', +134 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +135 +136 :return: list of properties for all triggers in the log group requested +137 +138 :raises KepHTTPError: If urllib provides an HTTPError +139 :raises KepURLError: If urllib provides an URLError +140 ''' +141 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) +142 return r.payload
32def add_trigger(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: -33 '''Add a `"trigger"` or multiple `"trigger"` objects to a log group in Kepware's Datalogger. It can -34 be used to pass a list of triggers to be added all at once. -35 -36 :param server: instance of the `server` class -37 :param log_group: name of log group for the trigger items -38 :param DATA: Dict or a list of the trigger items to add through Kepware Configuration API -39 -40 :return: True - If a "HTTP 201 - Created" is received from Kepware server -41 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -42 triggers added that failed. -43 -44 :raises KepHTTPError: If urllib provides an HTTPError -45 :raises KepURLError: If urllib provides an URLError -46 ''' -47 -48 r = server._config_add(server.url + Log_Group._create_url(log_group) + _create_url(), DATA) -49 if r.code == 201: return True -50 elif r.code == 207: -51 errors = [] -52 for item in r.payload: -53 if item['code'] != 201: -54 errors.append(item) -55 return errors -56 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -298,21 +299,21 @@33def add_trigger(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: +34 '''Add a `"trigger"` or multiple `"trigger"` objects to a log group in Kepware's Datalogger. It can +35 be used to pass a list of triggers to be added all at once. +36 +37 :param server: instance of the `server` class +38 :param log_group: name of log group for the trigger items +39 :param DATA: Dict or a list of the trigger items to add through Kepware Configuration API +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 triggers added that failed. +44 +45 :raises KepHTTPError: If urllib provides an HTTPError +46 :raises KepURLError: If urllib provides an URLError +47 ''' +48 +49 r = server._config_add(server.url + Log_Group._create_url(log_group) + _create_url(), DATA) +50 if r.code == 201: return True +51 elif r.code == 207: +52 errors = [] +53 for item in r.payload: +54 if item['code'] != 201: +55 errors.append(item) +56 return errors +57 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
58def del_trigger(server: server, log_group: str, trigger: str) -> bool: -59 '''Delete a `"trigger"` object of a log group in Kepware's Datalogger. -60 -61 :param server: instance of the `server` class -62 :param log_group: name of log group for the trigger items -63 :param trigger: name of trigger to delete -64 -65 :return: True - If a "HTTP 200 - OK" is received from Kepware server -66 -67 :raises KepHTTPError: If urllib provides an HTTPError -68 :raises KepURLError: If urllib provides an URLError -69 ''' -70 r = server._config_del(server.url + Log_Group._create_url(log_group) + _create_url(trigger)) -71 if r.code == 200: return True -72 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -353,39 +354,39 @@59def del_trigger(server: server, log_group: str, trigger: str) -> bool: +60 '''Delete a `"trigger"` object of a log group in Kepware's Datalogger. +61 +62 :param server: instance of the `server` class +63 :param log_group: name of log group for the trigger items +64 :param trigger: name of trigger to delete +65 +66 :return: True - If a "HTTP 200 - OK" is received from Kepware server +67 +68 :raises KepHTTPError: If urllib provides an HTTPError +69 :raises KepURLError: If urllib provides an URLError +70 ''' +71 r = server._config_del(server.url + Log_Group._create_url(log_group) + _create_url(trigger)) +72 if r.code == 200: return True +73 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
74def modify_trigger(server: server, log_group: str, DATA: dict, *, trigger: str = None, force: bool = False) -> bool: - 75 '''Modify a `"trigger"` object and it's properties in Kepware. If a `"trigger"` is not provided as an input, - 76 you need to identify the trigger in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 77 assume that is the trigger that is to be modified. - 78 - 79 :param server: instance of the `server` class - 80 :param log_group: name of log group for the trigger items - 81 :param DATA: Dict of the trigger properties to be modified. - 82 :param trigger: *(optional)* name of trigger to modify in the log group. Only needed if not existing in `"DATA"` - 83 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 84 - 85 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 86 - 87 :raises KepHTTPError: If urllib provides an HTTPError - 88 :raises KepURLError: If urllib provides an URLError - 89 ''' - 90 - 91 trigger_data = server._force_update_check(force, DATA) - 92 - 93 if trigger == None: - 94 try: - 95 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(trigger_data['common.ALLTYPES_NAME']), trigger_data) - 96 if r.code == 200: return True - 97 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 98 except KeyError as err: - 99 err_msg = 'Error: No trigger identified in DATA | Key Error: {}'.format(err) -100 raise KepError(err_msg) -101 # except: -102 # return 'Error: Error with {}'.format(inspect.currentframe().f_code.co_name) -103 else: -104 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(trigger), trigger_data) -105 if r.code == 200: return True -106 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -430,20 +431,20 @@75def modify_trigger(server: server, log_group: str, DATA: dict, *, trigger: str = None, force: bool = False) -> bool: + 76 '''Modify a `"trigger"` object and it's properties in Kepware. If a `"trigger"` is not provided as an input, + 77 you need to identify the trigger in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 78 assume that is the trigger that is to be modified. + 79 + 80 :param server: instance of the `server` class + 81 :param log_group: name of log group for the trigger items + 82 :param DATA: Dict of the trigger properties to be modified. + 83 :param trigger: *(optional)* name of trigger to modify in the log group. Only needed if not existing in `"DATA"` + 84 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 85 + 86 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 87 + 88 :raises KepHTTPError: If urllib provides an HTTPError + 89 :raises KepURLError: If urllib provides an URLError + 90 ''' + 91 + 92 trigger_data = server._force_update_check(force, DATA) + 93 + 94 if trigger == None: + 95 try: + 96 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(trigger_data['common.ALLTYPES_NAME']), trigger_data) + 97 if r.code == 200: return True + 98 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 99 except KeyError as err: +100 err_msg = 'Error: No trigger identified in DATA | Key Error: {}'.format(err) +101 raise KepError(err_msg) +102 # except: +103 # return 'Error: Error with {}'.format(inspect.currentframe().f_code.co_name) +104 else: +105 r = server._config_update(server.url + Log_Group._create_url(log_group) + _create_url(trigger), trigger_data) +106 if r.code == 200: return True +107 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
108def get_trigger(server, log_group, trigger) -> dict: -109 '''Returns the properties of the `"trigger"` object. -110 -111 :param server: instance of the `server` class -112 :param log_group: name of log group for the trigger items -113 :param trigger: name of trigger to retrieve -114 -115 :return: Dict of properties for the trigger requested -116 -117 :raises KepHTTPError: If urllib provides an HTTPError -118 :raises KepURLError: If urllib provides an URLError -119 ''' -120 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(trigger)) -121 return r.payload +@@ -484,26 +485,26 @@109def get_trigger(server, log_group, trigger) -> dict: +110 '''Returns the properties of the `"trigger"` object. +111 +112 :param server: instance of the `server` class +113 :param log_group: name of log group for the trigger items +114 :param trigger: name of trigger to retrieve +115 +116 :return: Dict of properties for the trigger requested +117 +118 :raises KepHTTPError: If urllib provides an HTTPError +119 :raises KepURLError: If urllib provides an URLError +120 ''' +121 r = server._config_get(server.url + Log_Group._create_url(log_group) + _create_url(trigger)) +122 return r.payloadRaises
123def get_all_triggers(server: server, log_group: str, *, options: dict = None) -> list: -124 '''Returns the properties of all `"trigger"` objects for a log group. -125 -126 :param server: instance of the `server` class -127 :param log_group: name of log group for the trigger items -128 -129 :return: Dict of properties for the trigger requested -130 -131 :raises KepHTTPError: If urllib provides an HTTPError -132 :raises KepURLError: If urllib provides an URLError -133 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of triggers. Options are 'filter', -134 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -135 -136 :return: list of properties for all triggers in the log group requested -137 -138 :raises KepHTTPError: If urllib provides an HTTPError -139 :raises KepURLError: If urllib provides an URLError -140 ''' -141 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) -142 return r.payload +diff --git a/docs/kepconfig/iot_gateway/agent.html b/docs/kepconfig/iot_gateway/agent.html index 773a2f8..c3f2797 100644 --- a/docs/kepconfig/iot_gateway/agent.html +++ b/docs/kepconfig/iot_gateway/agent.html @@ -86,171 +86,172 @@124def get_all_triggers(server: server, log_group: str, *, options: dict = None) -> list: +125 '''Returns the properties of all `"trigger"` objects for a log group. +126 +127 :param server: instance of the `server` class +128 :param log_group: name of log group for the trigger items +129 +130 :return: Dict of properties for the trigger requested +131 +132 :raises KepHTTPError: If urllib provides an HTTPError +133 :raises KepURLError: If urllib provides an URLError +134 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of triggers. Options are 'filter', +135 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +136 +137 :return: list of properties for all triggers in the log group requested +138 +139 :raises KepHTTPError: If urllib provides an HTTPError +140 :raises KepURLError: If urllib provides an URLError +141 ''' +142 r = server._config_get(f'{server.url}{Log_Group._create_url(log_group)}{_create_url()}', params= options) +143 return r.payload15from .. import iot_gateway as IOT 16from ..error import KepError, KepHTTPError 17import inspect - 18 - 19IOT_ROOT_URL = '/project/_iot_gateway' - 20MQTT_CLIENT_URL = '/mqtt_clients' - 21REST_CLIENT_URL = '/rest_clients' - 22REST_SERVER_URL = '/rest_servers' - 23THINGWORX_URL = '/thingworx_clients' - 24 - 25def _create_url(agent_type, agent = None): - 26 '''Creates url object for the "agent" branch of Kepware's project tree. Used - 27 to build a part of Kepware Configuration API URL structure - 28 - 29 Returns the agent specific url when a value is passed as the agent name. - 30 ''' - 31 - 32 if agent == None: - 33 if agent_type == IOT.MQTT_CLIENT_AGENT: - 34 return '{}{}'.format(IOT_ROOT_URL, MQTT_CLIENT_URL) - 35 elif agent_type == IOT.REST_CLIENT_AGENT: - 36 return '{}{}'.format(IOT_ROOT_URL, REST_CLIENT_URL) - 37 elif agent_type == IOT.REST_SERVER_AGENT: - 38 return '{}{}'.format(IOT_ROOT_URL, REST_SERVER_URL) - 39 elif agent_type == IOT.THINGWORX_AGENT: - 40 return '{}{}'.format(IOT_ROOT_URL, THINGWORX_URL) - 41 else: - 42 pass - 43 else: - 44 if agent_type == IOT.MQTT_CLIENT_AGENT: - 45 return '{}{}/{}'.format(IOT_ROOT_URL, MQTT_CLIENT_URL, agent) - 46 elif agent_type == IOT.REST_CLIENT_AGENT: - 47 return '{}{}/{}'.format(IOT_ROOT_URL, REST_CLIENT_URL, agent) - 48 elif agent_type == IOT.REST_SERVER_AGENT: - 49 return '{}{}/{}'.format(IOT_ROOT_URL, REST_SERVER_URL,agent) - 50 elif agent_type == IOT.THINGWORX_AGENT: - 51 return '{}{}/{}'.format(IOT_ROOT_URL, THINGWORX_URL, agent) - 52 else: - 53 pass - 54 + 18from ..utils import _url_parse_object + 19 + 20IOT_ROOT_URL = '/project/_iot_gateway' + 21MQTT_CLIENT_URL = '/mqtt_clients' + 22REST_CLIENT_URL = '/rest_clients' + 23REST_SERVER_URL = '/rest_servers' + 24THINGWORX_URL = '/thingworx_clients' + 25 + 26def _create_url(agent_type, agent = None): + 27 '''Creates url object for the "agent" branch of Kepware's project tree. Used + 28 to build a part of Kepware Configuration API URL structure + 29 + 30 Returns the agent specific url when a value is passed as the agent name. + 31 ''' + 32 + 33 if agent == None: + 34 if agent_type == IOT.MQTT_CLIENT_AGENT: + 35 return '{}{}'.format(IOT_ROOT_URL, MQTT_CLIENT_URL) + 36 elif agent_type == IOT.REST_CLIENT_AGENT: + 37 return '{}{}'.format(IOT_ROOT_URL, REST_CLIENT_URL) + 38 elif agent_type == IOT.REST_SERVER_AGENT: + 39 return '{}{}'.format(IOT_ROOT_URL, REST_SERVER_URL) + 40 elif agent_type == IOT.THINGWORX_AGENT: + 41 return '{}{}'.format(IOT_ROOT_URL, THINGWORX_URL) + 42 else: + 43 pass + 44 else: + 45 if agent_type == IOT.MQTT_CLIENT_AGENT: + 46 return '{}{}/{}'.format(IOT_ROOT_URL, MQTT_CLIENT_URL, _url_parse_object(agent)) + 47 elif agent_type == IOT.REST_CLIENT_AGENT: + 48 return '{}{}/{}'.format(IOT_ROOT_URL, REST_CLIENT_URL, _url_parse_object(agent)) + 49 elif agent_type == IOT.REST_SERVER_AGENT: + 50 return '{}{}/{}'.format(IOT_ROOT_URL, REST_SERVER_URL,_url_parse_object(agent)) + 51 elif agent_type == IOT.THINGWORX_AGENT: + 52 return '{}{}/{}'.format(IOT_ROOT_URL, THINGWORX_URL, _url_parse_object(agent)) + 53 else: + 54 pass 55 - 56def add_iot_agent(server: server, DATA: Union[dict, list], agent_type: str = None) -> Union[bool, list]: - 57 '''Add a `"agent"` or multiple `"agent"` objects of a specific type to Kepware's IoT Gateway. Can be used to pass children of an - 58 agent object such as iot items. This allows you to create an agent and iot items if desired. Multiple Agents need to be of the - 59 same type. - 60 - 61 Additionally it can be used to pass a list of agents and it's children to be added all at once. - 62 - 63 :param server: instance of the `server` class - 64 :param DATA: Dict or List of Dicts of the agent and it's children - 65 expected by Kepware Configuration API - 66 :param agent_type: *(optional)* agent type to add to IoT Gateway. Only needed if not existing in `"DATA"`. Valid values are - 67 `MQTT Client`, `REST Client` or `REST Server` - 68 - 69 :return: True - If a "HTTP 201 - Created" is received from Kepware server - 70 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all - 71 iot agents added that failed. - 72 - 73 :raises KepHTTPError: If urllib provides an HTTPError - 74 :raises KepURLError: If urllib provides an URLError - 75 ''' - 76 - 77 if agent_type == None: - 78 try: - 79 r = server._config_update(server.url + _create_url(DATA['iot_gateway.AGENTTYPES_TYPE']), DATA) - 80 if r.code == 201: return True - 81 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 82 except KeyError as err: - 83 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) - 84 raise KepError(err_msg) - 85 else: - 86 r = server._config_add(server.url + _create_url(agent_type), DATA) - 87 if r.code == 201: return True - 88 elif r.code == 207: - 89 errors = [] - 90 for item in r.payload: - 91 if item['code'] != 201: - 92 errors.append(item) - 93 return errors - 94 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 95 - 96def del_iot_agent(server: server, agent: str, agent_type: str) -> bool: - 97 '''Delete a `"agent"` object in Kepware. This will delete all children as well - 98 - 99 :param server: instance of the `server` class -100 :param agent: name of IoT Agent to delete -101 :param agent_type: *(optional)* agent type to delete in IoT Gateway. Valid values are -102 `MQTT Client`, `REST Client` or `REST Server` -103 -104 :return: True - If a "HTTP 200 - OK" is received from Kepware server -105 -106 :raises KepHTTPError: If urllib provides an HTTPError -107 :raises KepURLError: If urllib provides an URLError -108 ''' -109 r = server._config_del(server.url + _create_url(agent_type, agent)) -110 if r.code == 200: return True -111 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -112 -113def modify_iot_agent(server: server, DATA: dict, *, agent: str = None, agent_type: str = None, force: bool = False) -> bool: -114 '''Modify a `"agent"` object and it's properties in Kepware. If a `"agent"` is not provided as an input, -115 you need to identify the agent in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will -116 assume that is the agent that is to be modified. -117 -118 :param server: instance of the `server` class -119 :param DATA: Dict of the iot agent properties to be modified. -120 :param agent: *(optional)* name of IoT agent to modify. Only needed if not existing in `"DATA"` -121 :param agent_type: *(optional)* agent type to modify. Only needed if not existing in `"DATA"`. Valid values are -122 `MQTT Client`, `REST Client` or `REST Server` -123 :param force: *(optional)* if True, will force the configuration update to the Kepware server -124 -125 :return: True - If a "HTTP 200 - OK" is received from Kepware server -126 -127 :raises KepHTTPError: If urllib provides an HTTPError -128 :raises KepURLError: If urllib provides an URLError -129 ''' -130 -131 agent_data = server._force_update_check(force, DATA) -132 -133 if agent_type == None: -134 if 'iot_gateway.AGENTTYPES_TYPE' in DATA: -135 agent_type = DATA['iot_gateway.AGENTTYPES_TYPE'] -136 else: -137 err_msg = 'Error: Error with {}: {}'.format(inspect.currentframe().f_code.co_name, 'No Agent type defined.') -138 raise KepError(err_msg) -139 if agent == None: -140 try: -141 r = server._config_update(server.url + _create_url(agent_type, agent_data['common.ALLTYPES_NAME']), agent_data) -142 if r.code == 200: return True -143 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -144 except KeyError as err: -145 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) -146 raise KepError(err_msg) -147 else: -148 r = server._config_update(server.url + _create_url(agent_type, agent), agent_data) -149 if r.code == 200: return True -150 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -151 -152def get_iot_agent(server: server, agent: str, agent_type: str) -> dict: -153 '''Returns the properties of the `"agent"` object. -154 -155 :param server: instance of the `server` class -156 :param DATA: Dict of the iot agent properties to be modified. -157 :param agent: name of IoT agent to retrieve -158 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -159 -160 :return: Dict of properties for the iot agent requested -161 -162 :raises KepHTTPError: If urllib provides an HTTPError -163 :raises KepURLError: If urllib provides an URLError -164 ''' -165 r = server._config_get(server.url + _create_url(agent_type, agent)) -166 return r.payload -167 -168def get_all_iot_agents(server: server, agent_type: str, *, options: dict = None) -> list: -169 '''Returns the properties of all `"agent"` objects for a specific agent type. Returned object is JSON list. -170 -171 :param server: instance of the `server` class -172 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -173 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of IoT agents. Options are 'filter', -174 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -175 -176 :return: list of properties for all IoT agents requested -177 -178 :raises KepHTTPError: If urllib provides an HTTPError -179 :raises KepURLError: If urllib provides an URLError -180 ''' -181 r = server._config_get(f'{server.url}{_create_url(agent_type)}', params= options) -182 return r.payload + 56 + 57def add_iot_agent(server: server, DATA: Union[dict, list], agent_type: str = None) -> Union[bool, list]: + 58 '''Add a `"agent"` or multiple `"agent"` objects of a specific type to Kepware's IoT Gateway. Can be used to pass children of an + 59 agent object such as iot items. This allows you to create an agent and iot items if desired. Multiple Agents need to be of the + 60 same type. + 61 + 62 Additionally it can be used to pass a list of agents and it's children to be added all at once. + 63 + 64 :param server: instance of the `server` class + 65 :param DATA: Dict or List of Dicts of the agent and it's children + 66 expected by Kepware Configuration API + 67 :param agent_type: *(optional)* agent type to add to IoT Gateway. Only needed if not existing in `"DATA"`. Valid values are + 68 `MQTT Client`, `REST Client` or `REST Server` + 69 + 70 :return: True - If a "HTTP 201 - Created" is received from Kepware server + 71 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all + 72 iot agents added that failed. + 73 + 74 :raises KepHTTPError: If urllib provides an HTTPError + 75 :raises KepURLError: If urllib provides an URLError + 76 ''' + 77 + 78 if agent_type == None: + 79 try: + 80 # If it's a list, use the first agents type + 81 if isinstance(DATA, list): agent_type = DATA[0]['iot_gateway.AGENTTYPES_TYPE'] + 82 else: agent_type = DATA['iot_gateway.AGENTTYPES_TYPE'] + 83 except KeyError as err: + 84 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) + 85 raise KepError(err_msg) + 86 + 87 r = server._config_add(server.url + _create_url(agent_type), DATA) + 88 if r.code == 201: return True + 89 elif r.code == 207: + 90 errors = [] + 91 for item in r.payload: + 92 if item['code'] != 201: + 93 errors.append(item) + 94 return errors + 95 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 96 + 97def del_iot_agent(server: server, agent: str, agent_type: str) -> bool: + 98 '''Delete a `"agent"` object in Kepware. This will delete all children as well + 99 +100 :param server: instance of the `server` class +101 :param agent: name of IoT Agent to delete +102 :param agent_type: *(optional)* agent type to delete in IoT Gateway. Valid values are +103 `MQTT Client`, `REST Client` or `REST Server` +104 +105 :return: True - If a "HTTP 200 - OK" is received from Kepware server +106 +107 :raises KepHTTPError: If urllib provides an HTTPError +108 :raises KepURLError: If urllib provides an URLError +109 ''' +110 r = server._config_del(server.url + _create_url(agent_type, agent)) +111 if r.code == 200: return True +112 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +113 +114def modify_iot_agent(server: server, DATA: dict, *, agent: str = None, agent_type: str = None, force: bool = False) -> bool: +115 '''Modify a `"agent"` object and it's properties in Kepware. If a `"agent"` is not provided as an input, +116 you need to identify the agent in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will +117 assume that is the agent that is to be modified. +118 +119 :param server: instance of the `server` class +120 :param DATA: Dict of the iot agent properties to be modified. +121 :param agent: *(optional)* name of IoT agent to modify. Only needed if not existing in `"DATA"` +122 :param agent_type: *(optional)* agent type to modify. Only needed if not existing in `"DATA"`. Valid values are +123 `MQTT Client`, `REST Client` or `REST Server` +124 :param force: *(optional)* if True, will force the configuration update to the Kepware server +125 +126 :return: True - If a "HTTP 200 - OK" is received from Kepware server +127 +128 :raises KepHTTPError: If urllib provides an HTTPError +129 :raises KepURLError: If urllib provides an URLError +130 ''' +131 +132 agent_data = server._force_update_check(force, DATA) +133 +134 if agent_type == None: +135 if 'iot_gateway.AGENTTYPES_TYPE' in DATA: +136 agent_type = DATA['iot_gateway.AGENTTYPES_TYPE'] +137 else: +138 err_msg = 'Error: Error with {}: {}'.format(inspect.currentframe().f_code.co_name, 'No Agent type defined.') +139 raise KepError(err_msg) +140 if agent == None: +141 try: +142 r = server._config_update(server.url + _create_url(agent_type, agent_data['common.ALLTYPES_NAME']), agent_data) +143 if r.code == 200: return True +144 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +145 except KeyError as err: +146 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) +147 raise KepError(err_msg) +148 else: +149 r = server._config_update(server.url + _create_url(agent_type, agent), agent_data) +150 if r.code == 200: return True +151 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +152 +153def get_iot_agent(server: server, agent: str, agent_type: str) -> dict: +154 '''Returns the properties of the `"agent"` object. +155 +156 :param server: instance of the `server` class +157 :param DATA: Dict of the iot agent properties to be modified. +158 :param agent: name of IoT agent to retrieve +159 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +160 +161 :return: Dict of properties for the iot agent requested +162 +163 :raises KepHTTPError: If urllib provides an HTTPError +164 :raises KepURLError: If urllib provides an URLError +165 ''' +166 r = server._config_get(server.url + _create_url(agent_type, agent)) +167 return r.payload +168 +169def get_all_iot_agents(server: server, agent_type: str, *, options: dict = None) -> list: +170 '''Returns the properties of all `"agent"` objects for a specific agent type. Returned object is JSON list. +171 +172 :param server: instance of the `server` class +173 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +174 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of IoT agents. Options are 'filter', +175 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +176 +177 :return: list of properties for all IoT agents requested +178 +179 :raises KepHTTPError: If urllib provides an HTTPError +180 :raises KepURLError: If urllib provides an URLError +181 ''' +182 r = server._config_get(f'{server.url}{_create_url(agent_type)}', params= options) +183 return r.payload
57def add_iot_agent(server: server, DATA: Union[dict, list], agent_type: str = None) -> Union[bool, list]: -58 '''Add a `"agent"` or multiple `"agent"` objects of a specific type to Kepware's IoT Gateway. Can be used to pass children of an -59 agent object such as iot items. This allows you to create an agent and iot items if desired. Multiple Agents need to be of the -60 same type. -61 -62 Additionally it can be used to pass a list of agents and it's children to be added all at once. -63 -64 :param server: instance of the `server` class -65 :param DATA: Dict or List of Dicts of the agent and it's children -66 expected by Kepware Configuration API -67 :param agent_type: *(optional)* agent type to add to IoT Gateway. Only needed if not existing in `"DATA"`. Valid values are -68 `MQTT Client`, `REST Client` or `REST Server` -69 -70 :return: True - If a "HTTP 201 - Created" is received from Kepware server -71 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -72 iot agents added that failed. -73 -74 :raises KepHTTPError: If urllib provides an HTTPError -75 :raises KepURLError: If urllib provides an URLError -76 ''' -77 -78 if agent_type == None: -79 try: -80 r = server._config_update(server.url + _create_url(DATA['iot_gateway.AGENTTYPES_TYPE']), DATA) -81 if r.code == 201: return True -82 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -83 except KeyError as err: -84 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) -85 raise KepError(err_msg) -86 else: -87 r = server._config_add(server.url + _create_url(agent_type), DATA) -88 if r.code == 201: return True -89 elif r.code == 207: -90 errors = [] -91 for item in r.payload: -92 if item['code'] != 201: -93 errors.append(item) -94 return errors -95 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -358,22 +359,22 @@58def add_iot_agent(server: server, DATA: Union[dict, list], agent_type: str = None) -> Union[bool, list]: +59 '''Add a `"agent"` or multiple `"agent"` objects of a specific type to Kepware's IoT Gateway. Can be used to pass children of an +60 agent object such as iot items. This allows you to create an agent and iot items if desired. Multiple Agents need to be of the +61 same type. +62 +63 Additionally it can be used to pass a list of agents and it's children to be added all at once. +64 +65 :param server: instance of the `server` class +66 :param DATA: Dict or List of Dicts of the agent and it's children +67 expected by Kepware Configuration API +68 :param agent_type: *(optional)* agent type to add to IoT Gateway. Only needed if not existing in `"DATA"`. Valid values are +69 `MQTT Client`, `REST Client` or `REST Server` +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 iot agents added that failed. +74 +75 :raises KepHTTPError: If urllib provides an HTTPError +76 :raises KepURLError: If urllib provides an URLError +77 ''' +78 +79 if agent_type == None: +80 try: +81 # If it's a list, use the first agents type +82 if isinstance(DATA, list): agent_type = DATA[0]['iot_gateway.AGENTTYPES_TYPE'] +83 else: agent_type = DATA['iot_gateway.AGENTTYPES_TYPE'] +84 except KeyError as err: +85 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) +86 raise KepError(err_msg) +87 +88 r = server._config_add(server.url + _create_url(agent_type), DATA) +89 if r.code == 201: return True +90 elif r.code == 207: +91 errors = [] +92 for item in r.payload: +93 if item['code'] != 201: +94 errors.append(item) +95 return errors +96 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
97def del_iot_agent(server: server, agent: str, agent_type: str) -> bool: - 98 '''Delete a `"agent"` object in Kepware. This will delete all children as well - 99 -100 :param server: instance of the `server` class -101 :param agent: name of IoT Agent to delete -102 :param agent_type: *(optional)* agent type to delete in IoT Gateway. Valid values are -103 `MQTT Client`, `REST Client` or `REST Server` -104 -105 :return: True - If a "HTTP 200 - OK" is received from Kepware server -106 -107 :raises KepHTTPError: If urllib provides an HTTPError -108 :raises KepURLError: If urllib provides an URLError -109 ''' -110 r = server._config_del(server.url + _create_url(agent_type, agent)) -111 if r.code == 200: return True -112 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -415,44 +416,44 @@98def del_iot_agent(server: server, agent: str, agent_type: str) -> bool: + 99 '''Delete a `"agent"` object in Kepware. This will delete all children as well +100 +101 :param server: instance of the `server` class +102 :param agent: name of IoT Agent to delete +103 :param agent_type: *(optional)* agent type to delete in IoT Gateway. Valid values are +104 `MQTT Client`, `REST Client` or `REST Server` +105 +106 :return: True - If a "HTTP 200 - OK" is received from Kepware server +107 +108 :raises KepHTTPError: If urllib provides an HTTPError +109 :raises KepURLError: If urllib provides an URLError +110 ''' +111 r = server._config_del(server.url + _create_url(agent_type, agent)) +112 if r.code == 200: return True +113 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
114def modify_iot_agent(server: server, DATA: dict, *, agent: str = None, agent_type: str = None, force: bool = False) -> bool: -115 '''Modify a `"agent"` object and it's properties in Kepware. If a `"agent"` is not provided as an input, -116 you need to identify the agent in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will -117 assume that is the agent that is to be modified. -118 -119 :param server: instance of the `server` class -120 :param DATA: Dict of the iot agent properties to be modified. -121 :param agent: *(optional)* name of IoT agent to modify. Only needed if not existing in `"DATA"` -122 :param agent_type: *(optional)* agent type to modify. Only needed if not existing in `"DATA"`. Valid values are -123 `MQTT Client`, `REST Client` or `REST Server` -124 :param force: *(optional)* if True, will force the configuration update to the Kepware server -125 -126 :return: True - If a "HTTP 200 - OK" is received from Kepware server -127 -128 :raises KepHTTPError: If urllib provides an HTTPError -129 :raises KepURLError: If urllib provides an URLError -130 ''' -131 -132 agent_data = server._force_update_check(force, DATA) -133 -134 if agent_type == None: -135 if 'iot_gateway.AGENTTYPES_TYPE' in DATA: -136 agent_type = DATA['iot_gateway.AGENTTYPES_TYPE'] -137 else: -138 err_msg = 'Error: Error with {}: {}'.format(inspect.currentframe().f_code.co_name, 'No Agent type defined.') -139 raise KepError(err_msg) -140 if agent == None: -141 try: -142 r = server._config_update(server.url + _create_url(agent_type, agent_data['common.ALLTYPES_NAME']), agent_data) -143 if r.code == 200: return True -144 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -145 except KeyError as err: -146 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) -147 raise KepError(err_msg) -148 else: -149 r = server._config_update(server.url + _create_url(agent_type, agent), agent_data) -150 if r.code == 200: return True -151 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -498,21 +499,21 @@115def modify_iot_agent(server: server, DATA: dict, *, agent: str = None, agent_type: str = None, force: bool = False) -> bool: +116 '''Modify a `"agent"` object and it's properties in Kepware. If a `"agent"` is not provided as an input, +117 you need to identify the agent in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will +118 assume that is the agent that is to be modified. +119 +120 :param server: instance of the `server` class +121 :param DATA: Dict of the iot agent properties to be modified. +122 :param agent: *(optional)* name of IoT agent to modify. Only needed if not existing in `"DATA"` +123 :param agent_type: *(optional)* agent type to modify. Only needed if not existing in `"DATA"`. Valid values are +124 `MQTT Client`, `REST Client` or `REST Server` +125 :param force: *(optional)* if True, will force the configuration update to the Kepware server +126 +127 :return: True - If a "HTTP 200 - OK" is received from Kepware server +128 +129 :raises KepHTTPError: If urllib provides an HTTPError +130 :raises KepURLError: If urllib provides an URLError +131 ''' +132 +133 agent_data = server._force_update_check(force, DATA) +134 +135 if agent_type == None: +136 if 'iot_gateway.AGENTTYPES_TYPE' in DATA: +137 agent_type = DATA['iot_gateway.AGENTTYPES_TYPE'] +138 else: +139 err_msg = 'Error: Error with {}: {}'.format(inspect.currentframe().f_code.co_name, 'No Agent type defined.') +140 raise KepError(err_msg) +141 if agent == None: +142 try: +143 r = server._config_update(server.url + _create_url(agent_type, agent_data['common.ALLTYPES_NAME']), agent_data) +144 if r.code == 200: return True +145 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +146 except KeyError as err: +147 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) +148 raise KepError(err_msg) +149 else: +150 r = server._config_update(server.url + _create_url(agent_type, agent), agent_data) +151 if r.code == 200: return True +152 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
153def get_iot_agent(server: server, agent: str, agent_type: str) -> dict: -154 '''Returns the properties of the `"agent"` object. -155 -156 :param server: instance of the `server` class -157 :param DATA: Dict of the iot agent properties to be modified. -158 :param agent: name of IoT agent to retrieve -159 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -160 -161 :return: Dict of properties for the iot agent requested -162 -163 :raises KepHTTPError: If urllib provides an HTTPError -164 :raises KepURLError: If urllib provides an URLError -165 ''' -166 r = server._config_get(server.url + _create_url(agent_type, agent)) -167 return r.payload +@@ -554,21 +555,21 @@154def get_iot_agent(server: server, agent: str, agent_type: str) -> dict: +155 '''Returns the properties of the `"agent"` object. +156 +157 :param server: instance of the `server` class +158 :param DATA: Dict of the iot agent properties to be modified. +159 :param agent: name of IoT agent to retrieve +160 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +161 +162 :return: Dict of properties for the iot agent requested +163 +164 :raises KepHTTPError: If urllib provides an HTTPError +165 :raises KepURLError: If urllib provides an URLError +166 ''' +167 r = server._config_get(server.url + _create_url(agent_type, agent)) +168 return r.payloadRaises
169def get_all_iot_agents(server: server, agent_type: str, *, options: dict = None) -> list: -170 '''Returns the properties of all `"agent"` objects for a specific agent type. Returned object is JSON list. -171 -172 :param server: instance of the `server` class -173 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -174 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of IoT agents. Options are 'filter', -175 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -176 -177 :return: list of properties for all IoT agents requested -178 -179 :raises KepHTTPError: If urllib provides an HTTPError -180 :raises KepURLError: If urllib provides an URLError -181 ''' -182 r = server._config_get(f'{server.url}{_create_url(agent_type)}', params= options) -183 return r.payload +diff --git a/docs/kepconfig/iot_gateway/iot_items.html b/docs/kepconfig/iot_gateway/iot_items.html index a69ed3c..00c5604 100644 --- a/docs/kepconfig/iot_gateway/iot_items.html +++ b/docs/kepconfig/iot_gateway/iot_items.html @@ -85,131 +85,132 @@170def get_all_iot_agents(server: server, agent_type: str, *, options: dict = None) -> list: +171 '''Returns the properties of all `"agent"` objects for a specific agent type. Returned object is JSON list. +172 +173 :param server: instance of the `server` class +174 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +175 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of IoT agents. Options are 'filter', +176 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +177 +178 :return: list of properties for all IoT agents requested +179 +180 :raises KepHTTPError: If urllib provides an HTTPError +181 :raises KepURLError: If urllib provides an URLError +182 ''' +183 r = server._config_get(f'{server.url}{_create_url(agent_type)}', params= options) +184 return r.payload14from ..connection import server 15from .. import iot_gateway as IOT 16from ..error import KepError, KepHTTPError - 17 - 18IOT_ITEMS_ROOT = '/iot_items' - 19 - 20def _create_url(tag = None): - 21 '''Creates url object for the "iot items" branch of Kepware's IoT Agents property model. Used - 22 to build a part of Kepware Configuration API URL structure - 23 - 24 Returns the device specific url when a value is passed as the iot item name. - 25 ''' - 26 if tag == None: - 27 return IOT_ITEMS_ROOT - 28 else: - 29 normalized_tag = utils._address_dedecimal(tag) - 30 return '{}/{}'.format(IOT_ITEMS_ROOT,normalized_tag) - 31 + 17from ..utils import _url_parse_object + 18 + 19IOT_ITEMS_ROOT = '/iot_items' + 20 + 21def _create_url(tag = None): + 22 '''Creates url object for the "iot items" branch of Kepware's IoT Agents property model. Used + 23 to build a part of Kepware Configuration API URL structure + 24 + 25 Returns the device specific url when a value is passed as the iot item name. + 26 ''' + 27 if tag == None: + 28 return IOT_ITEMS_ROOT + 29 else: + 30 normalized_tag = utils._address_dedecimal(tag) + 31 return '{}/{}'.format(IOT_ITEMS_ROOT, _url_parse_object(normalized_tag)) 32 - 33def add_iot_item(server: server, DATA: Union[dict, list], agent: str, agent_type: str) -> Union[bool, list]: - 34 '''Add a `"iot item"` or multiple `"iot item"` objects to Kepware's IoT Gateway agent. Additionally - 35 it can be used to pass a list of iot items to be added to an agent all at once. - 36 - 37 :param server: instance of the `server` class - 38 :param DATA: Dict or List of Dicts of the iot item or list of items - 39 expected by Kepware Configuration API - 40 :param agent: name of IoT Agent - 41 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` - 42 - 43 :return: True - If a "HTTP 201 - Created" is received from Kepware server - 44 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all - 45 iot items added that failed. - 46 - 47 :raises KepHTTPError: If urllib provides an HTTPError - 48 :raises KepURLError: If urllib provides an URLError - 49 ''' - 50 r = server._config_add(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(), DATA) - 51 if r.code == 201: return True - 52 elif r.code == 207: - 53 errors = [] - 54 for item in r.payload: - 55 if item['code'] != 201: - 56 errors.append(item) - 57 return errors - 58 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 59 - 60def del_iot_item(server: server, iot_item: str, agent: str, agent_type: str) -> bool: - 61 '''Delete an `"iot item"` object in Kepware. - 62 - 63 :param server: instance of the `server` class - 64 :param iot_item: IoT item to delete - 65 :param agent: name of IoT Agent - 66 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` - 67 - 68 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 69 - 70 :raises KepHTTPError: If urllib provides an HTTPError - 71 :raises KepURLError: If urllib provides an URLError - 72 ''' - 73 r = server._config_del(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item)) - 74 if r.code == 200: return True - 75 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) - 76 - 77def modify_iot_item(server: server, DATA: dict, agent: str, agent_type: str, *, iot_item: str = None, force: bool = False) -> bool: - 78 '''Modify an `"iot item"` object and it's properties in Kepware. If a `"iot item"` is not provided as an input, - 79 you need to identify the iot item in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 80 assume that is the iot item that is to be modified. - 81 - 82 :param server: instance of the `server` class - 83 :param DATA: Dict of the iot item properties to be modified. - 84 :param agent: name of IoT Agent - 85 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` - 86 :param iot_item: *(optional)* name of IoT item to modify. Only needed if not existing in `"DATA"` - 87 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 88 - 89 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 90 - 91 :raises KepHTTPError: If urllib provides an HTTPError - 92 :raises KepURLError: If urllib provides an URLError - 93 ''' - 94 - 95 agent_data = server._force_update_check(force, DATA) - 96 if iot_item == None: - 97 try: - 98 r = server._config_update(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(agent_data['common.ALLTYPES_NAME']), agent_data) - 99 if r.code == 200: return True -100 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -101 except KeyError as err: -102 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) -103 raise KepError(err_msg) -104 else: -105 r = server._config_update(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item), agent_data) -106 if r.code == 200: return True -107 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -108 -109def get_iot_item(server: server, iot_item: str, agent: str, agent_type: str)-> dict: -110 '''Returns the properties of the `"iot item"` object. -111 -112 :param server: instance of the `server` class -113 :param iot_item: name of IoT item to retrieve properties -114 :param agent: name of IoT Agent -115 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -116 -117 :return: Dict of properties for the iot item requested -118 -119 :raises KepHTTPError: If urllib provides an HTTPError -120 :raises KepURLError: If urllib provides an URLError -121 ''' -122 r = server._config_get(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item)) -123 return r.payload -124 -125def get_all_iot_items(server: server, agent: str, agent_type: str, *, options: dict = None) -> list: -126 '''Returns the properties of all `"iot item"` objects for an agent. -127 -128 :param server: instance of the `server` class -129 :param iot_item: name of IoT item to retrieve properties -130 :param agent: name of IoT Agent -131 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -132 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of IoT items. Options are 'filter', -133 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -134 -135 :return: list of properties for all IoT items -136 -137 :raises KepHTTPError: If urllib provides an HTTPError -138 :raises KepURLError: If urllib provides an URLError -139 ''' -140 r = server._config_get(f'{server.url}{IOT.agent._create_url(agent_type, agent)}{_create_url()}', params= options) -141 return r.payload + 33 + 34def add_iot_item(server: server, DATA: Union[dict, list], agent: str, agent_type: str) -> Union[bool, list]: + 35 '''Add a `"iot item"` or multiple `"iot item"` objects to Kepware's IoT Gateway agent. Additionally + 36 it can be used to pass a list of iot items to be added to an agent all at once. + 37 + 38 :param server: instance of the `server` class + 39 :param DATA: Dict or List of Dicts of the iot item or list of items + 40 expected by Kepware Configuration API + 41 :param agent: name of IoT Agent + 42 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` + 43 + 44 :return: True - If a "HTTP 201 - Created" is received from Kepware server + 45 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all + 46 iot items added that failed. + 47 + 48 :raises KepHTTPError: If urllib provides an HTTPError + 49 :raises KepURLError: If urllib provides an URLError + 50 ''' + 51 r = server._config_add(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(), DATA) + 52 if r.code == 201: return True + 53 elif r.code == 207: + 54 errors = [] + 55 for item in r.payload: + 56 if item['code'] != 201: + 57 errors.append(item) + 58 return errors + 59 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 60 + 61def del_iot_item(server: server, iot_item: str, agent: str, agent_type: str) -> bool: + 62 '''Delete an `"iot item"` object in Kepware. + 63 + 64 :param server: instance of the `server` class + 65 :param iot_item: IoT item to delete + 66 :param agent: name of IoT Agent + 67 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST 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 ''' + 74 r = server._config_del(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item)) + 75 if r.code == 200: return True + 76 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + 77 + 78def modify_iot_item(server: server, DATA: dict, agent: str, agent_type: str, *, iot_item: str = None, force: bool = False) -> bool: + 79 '''Modify an `"iot item"` object and it's properties in Kepware. If a `"iot item"` is not provided as an input, + 80 you need to identify the iot item in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 81 assume that is the iot item that is to be modified. + 82 + 83 :param server: instance of the `server` class + 84 :param DATA: Dict of the iot item properties to be modified. + 85 :param agent: name of IoT Agent + 86 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` + 87 :param iot_item: *(optional)* name of IoT item to modify. Only needed if not existing in `"DATA"` + 88 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 89 + 90 :return: True - If a "HTTP 200 - OK" is received from Kepware server + 91 + 92 :raises KepHTTPError: If urllib provides an HTTPError + 93 :raises KepURLError: If urllib provides an URLError + 94 ''' + 95 + 96 agent_data = server._force_update_check(force, DATA) + 97 if iot_item == None: + 98 try: + 99 r = server._config_update(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(agent_data['common.ALLTYPES_NAME']), agent_data) +100 if r.code == 200: return True +101 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +102 except KeyError as err: +103 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) +104 raise KepError(err_msg) +105 else: +106 r = server._config_update(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item), agent_data) +107 if r.code == 200: return True +108 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +109 +110def get_iot_item(server: server, iot_item: str, agent: str, agent_type: str)-> dict: +111 '''Returns the properties of the `"iot item"` object. +112 +113 :param server: instance of the `server` class +114 :param iot_item: name of IoT item to retrieve properties +115 :param agent: name of IoT Agent +116 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +117 +118 :return: Dict of properties for the iot item requested +119 +120 :raises KepHTTPError: If urllib provides an HTTPError +121 :raises KepURLError: If urllib provides an URLError +122 ''' +123 r = server._config_get(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item)) +124 return r.payload +125 +126def get_all_iot_items(server: server, agent: str, agent_type: str, *, options: dict = None) -> list: +127 '''Returns the properties of all `"iot item"` objects for an agent. +128 +129 :param server: instance of the `server` class +130 :param iot_item: name of IoT item to retrieve properties +131 :param agent: name of IoT Agent +132 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +133 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of IoT items. Options are 'filter', +134 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +135 +136 :return: list of properties for all IoT items +137 +138 :raises KepHTTPError: If urllib provides an HTTPError +139 :raises KepURLError: If urllib provides an URLError +140 ''' +141 r = server._config_get(f'{server.url}{IOT.agent._create_url(agent_type, agent)}{_create_url()}', params= options) +142 return r.payload
34def add_iot_item(server: server, DATA: Union[dict, list], agent: str, agent_type: str) -> Union[bool, list]: -35 '''Add a `"iot item"` or multiple `"iot item"` objects to Kepware's IoT Gateway agent. Additionally -36 it can be used to pass a list of iot items to be added to an agent all at once. -37 -38 :param server: instance of the `server` class -39 :param DATA: Dict or List of Dicts of the iot item or list of items -40 expected by Kepware Configuration API -41 :param agent: name of IoT Agent -42 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -43 -44 :return: True - If a "HTTP 201 - Created" is received from Kepware server -45 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all -46 iot items added that failed. -47 -48 :raises KepHTTPError: If urllib provides an HTTPError -49 :raises KepURLError: If urllib provides an URLError -50 ''' -51 r = server._config_add(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(), DATA) -52 if r.code == 201: return True -53 elif r.code == 207: -54 errors = [] -55 for item in r.payload: -56 if item['code'] != 201: -57 errors.append(item) -58 return errors -59 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -301,22 +302,22 @@35def add_iot_item(server: server, DATA: Union[dict, list], agent: str, agent_type: str) -> Union[bool, list]: +36 '''Add a `"iot item"` or multiple `"iot item"` objects to Kepware's IoT Gateway agent. Additionally +37 it can be used to pass a list of iot items to be added to an agent all at once. +38 +39 :param server: instance of the `server` class +40 :param DATA: Dict or List of Dicts of the iot item or list of items +41 expected by Kepware Configuration API +42 :param agent: name of IoT Agent +43 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +44 +45 :return: True - If a "HTTP 201 - Created" is received from Kepware server +46 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all +47 iot items added that failed. +48 +49 :raises KepHTTPError: If urllib provides an HTTPError +50 :raises KepURLError: If urllib provides an URLError +51 ''' +52 r = server._config_add(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(), DATA) +53 if r.code == 201: return True +54 elif r.code == 207: +55 errors = [] +56 for item in r.payload: +57 if item['code'] != 201: +58 errors.append(item) +59 return errors +60 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
61def del_iot_item(server: server, iot_item: str, agent: str, agent_type: str) -> bool: -62 '''Delete an `"iot item"` object in Kepware. -63 -64 :param server: instance of the `server` class -65 :param iot_item: IoT item to delete -66 :param agent: name of IoT Agent -67 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST 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 ''' -74 r = server._config_del(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item)) -75 if r.code == 200: return True -76 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -358,37 +359,37 @@62def del_iot_item(server: server, iot_item: str, agent: str, agent_type: str) -> bool: +63 '''Delete an `"iot item"` object in Kepware. +64 +65 :param server: instance of the `server` class +66 :param iot_item: IoT item to delete +67 :param agent: name of IoT Agent +68 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST 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 ''' +75 r = server._config_del(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item)) +76 if r.code == 200: return True +77 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
78def modify_iot_item(server: server, DATA: dict, agent: str, agent_type: str, *, iot_item: str = None, force: bool = False) -> bool: - 79 '''Modify an `"iot item"` object and it's properties in Kepware. If a `"iot item"` is not provided as an input, - 80 you need to identify the iot item in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will - 81 assume that is the iot item that is to be modified. - 82 - 83 :param server: instance of the `server` class - 84 :param DATA: Dict of the iot item properties to be modified. - 85 :param agent: name of IoT Agent - 86 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` - 87 :param iot_item: *(optional)* name of IoT item to modify. Only needed if not existing in `"DATA"` - 88 :param force: *(optional)* if True, will force the configuration update to the Kepware server - 89 - 90 :return: True - If a "HTTP 200 - OK" is received from Kepware server - 91 - 92 :raises KepHTTPError: If urllib provides an HTTPError - 93 :raises KepURLError: If urllib provides an URLError - 94 ''' - 95 - 96 agent_data = server._force_update_check(force, DATA) - 97 if iot_item == None: - 98 try: - 99 r = server._config_update(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(agent_data['common.ALLTYPES_NAME']), agent_data) -100 if r.code == 200: return True -101 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) -102 except KeyError as err: -103 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) -104 raise KepError(err_msg) -105 else: -106 r = server._config_update(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item), agent_data) -107 if r.code == 200: return True -108 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +@@ -434,21 +435,21 @@79def modify_iot_item(server: server, DATA: dict, agent: str, agent_type: str, *, iot_item: str = None, force: bool = False) -> bool: + 80 '''Modify an `"iot item"` object and it's properties in Kepware. If a `"iot item"` is not provided as an input, + 81 you need to identify the iot item in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will + 82 assume that is the iot item that is to be modified. + 83 + 84 :param server: instance of the `server` class + 85 :param DATA: Dict of the iot item properties to be modified. + 86 :param agent: name of IoT Agent + 87 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` + 88 :param iot_item: *(optional)* name of IoT item to modify. Only needed if not existing in `"DATA"` + 89 :param force: *(optional)* if True, will force the configuration update to the Kepware server + 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 ''' + 96 + 97 agent_data = server._force_update_check(force, DATA) + 98 if iot_item == None: + 99 try: +100 r = server._config_update(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(agent_data['common.ALLTYPES_NAME']), agent_data) +101 if r.code == 200: return True +102 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) +103 except KeyError as err: +104 err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) +105 raise KepError(err_msg) +106 else: +107 r = server._config_update(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item), agent_data) +108 if r.code == 200: return True +109 else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)Raises
110def get_iot_item(server: server, iot_item: str, agent: str, agent_type: str)-> dict: -111 '''Returns the properties of the `"iot item"` object. -112 -113 :param server: instance of the `server` class -114 :param iot_item: name of IoT item to retrieve properties -115 :param agent: name of IoT Agent -116 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -117 -118 :return: Dict of properties for the iot item requested -119 -120 :raises KepHTTPError: If urllib provides an HTTPError -121 :raises KepURLError: If urllib provides an URLError -122 ''' -123 r = server._config_get(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item)) -124 return r.payload +@@ -490,23 +491,23 @@111def get_iot_item(server: server, iot_item: str, agent: str, agent_type: str)-> dict: +112 '''Returns the properties of the `"iot item"` object. +113 +114 :param server: instance of the `server` class +115 :param iot_item: name of IoT item to retrieve properties +116 :param agent: name of IoT Agent +117 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +118 +119 :return: Dict of properties for the iot item requested +120 +121 :raises KepHTTPError: If urllib provides an HTTPError +122 :raises KepURLError: If urllib provides an URLError +123 ''' +124 r = server._config_get(server.url + IOT.agent._create_url(agent_type, agent) + _create_url(iot_item)) +125 return r.payloadRaises
126def get_all_iot_items(server: server, agent: str, agent_type: str, *, options: dict = None) -> list: -127 '''Returns the properties of all `"iot item"` objects for an agent. -128 -129 :param server: instance of the `server` class -130 :param iot_item: name of IoT item to retrieve properties -131 :param agent: name of IoT Agent -132 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` -133 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of IoT items. Options are 'filter', -134 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. -135 -136 :return: list of properties for all IoT items -137 -138 :raises KepHTTPError: If urllib provides an HTTPError -139 :raises KepURLError: If urllib provides an URLError -140 ''' -141 r = server._config_get(f'{server.url}{IOT.agent._create_url(agent_type, agent)}{_create_url()}', params= options) -142 return r.payload +diff --git a/docs/kepconfig/utils.html b/docs/kepconfig/utils.html index 4d4712b..ef3c935 100644 --- a/docs/kepconfig/utils.html +++ b/docs/kepconfig/utils.html @@ -67,38 +67,50 @@127def get_all_iot_items(server: server, agent: str, agent_type: str, *, options: dict = None) -> list: +128 '''Returns the properties of all `"iot item"` objects for an agent. +129 +130 :param server: instance of the `server` class +131 :param iot_item: name of IoT item to retrieve properties +132 :param agent: name of IoT Agent +133 :param agent_type: agent type. Valid values are `MQTT Client`, `REST Client` or `REST Server` +134 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of IoT items. Options are 'filter', +135 'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined. +136 +137 :return: list of properties for all IoT items +138 +139 :raises KepHTTPError: If urllib provides an HTTPError +140 :raises KepURLError: If urllib provides an URLError +141 ''' +142 r = server._config_get(f'{server.url}{IOT.agent._create_url(agent_type, agent)}{_create_url()}', params= options) +143 return r.payload8various objects for Kepware's configuration 9""" 10 -11def path_split(path: str): -12 '''Used to split the standard Kepware address decimal notation into a dict that contains the -13 *channel*, *device* and *tag_path* keys. -14 -15 :param path: standard Kepware address in decimal notation ("ch1.dev1.tg1.tg2.tg3") -16 :return: dict that contains the "channel", "device" and "tag_path" -17 :rtype: dict -18 -19 Ex: path = "ch1.dev1.tg1.tg2.tg3" +11from urllib import parse +12 +13def path_split(path: str): +14 '''Used to split the standard Kepware address decimal notation into a dict that contains the +15 *channel*, *device* and *tag_path* keys. +16 +17 :param path: standard Kepware address in decimal notation ("ch1.dev1.tg1.tg2.tg3") +18 :return: dict that contains the "channel", "device" and "tag_path" +19 :rtype: dict 20 -21 return = {'channel': 'ch1', 'device': 'dev1', 'tag_path': ['tg1','tg2','tg3']} +21 Ex: path = "ch1.dev1.tg1.tg2.tg3" 22 -23 Ex: path = "ch1.dev1" +23 return = {'channel': 'ch1', 'device': 'dev1', 'tag_path': ['tg1','tg2','tg3']} 24 -25 return = {'channel': 'ch1', 'device': 'dev1'} -26 ''' -27 path_list = path.split('.', 2) -28 path_obj = {} -29 for x in range(0, len(path_list)): -30 if x == 0: -31 path_obj['channel'] = path_list[0] -32 elif x == 1: -33 path_obj['device'] = path_list[1] -34 else: -35 path_obj['tag_path'] = path_list[2].split('.') -36 return path_obj -37 -38def _address_dedecimal(tag_address): -39 if tag_address[0] == '_': -40 tag_address = tag_address[1::] -41 updated = tag_address.replace('.','_') -42 return updated +25 Ex: path = "ch1.dev1" +26 +27 return = {'channel': 'ch1', 'device': 'dev1'} +28 ''' +29 path_list = path.split('.', 2) +30 path_obj = {} +31 for x in range(0, len(path_list)): +32 if x == 0: +33 path_obj['channel'] = path_list[0] +34 elif x == 1: +35 path_obj['device'] = path_list[1] +36 else: +37 path_obj['tag_path'] = path_list[2].split('.') +38 return path_obj +39 +40def _address_dedecimal(tag_address): +41 '''Used to handle URL references where decimal notation isn't supported in object names, i.e. IoT Gateway items. +42 +43 Replaces `.` with `_` and removes leading `_` for system tag references''' +44 if tag_address[0] == '_': +45 tag_address = tag_address[1::] +46 updated = tag_address.replace('.','_') +47 return updated +48 +49def _url_parse_object(object): +50 '''Common url parse to handle reserved characters. Used to convert object +51 names when building URLs. +52 +53 Reserved character list that Kepware allows in object names: :/?#[]@!$&'()*+,;=''' +54 return parse.quote(object, safe='')
12def path_split(path: str): -13 '''Used to split the standard Kepware address decimal notation into a dict that contains the -14 *channel*, *device* and *tag_path* keys. -15 -16 :param path: standard Kepware address in decimal notation ("ch1.dev1.tg1.tg2.tg3") -17 :return: dict that contains the "channel", "device" and "tag_path" -18 :rtype: dict -19 -20 Ex: path = "ch1.dev1.tg1.tg2.tg3" +diff --git a/docs/search.js b/docs/search.js index c118a5d..282e5df 100644 --- a/docs/search.js +++ b/docs/search.js @@ -1,6 +1,6 @@ window.pdocSearch = (function(){ /** elasticlunr - http://weixsong.github.io * Copyright (C) 2017 Oliver Nightingale * Copyright (C) 2017 Wei Song * MIT Licensed */!function(){function e(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.9.5",lunr=t,t.utils={},t.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),t.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},t.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!==n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},t.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},t.EventEmitter.prototype.hasHandler=function(e){return e in this.events},t.tokenizer=function(e){if(!arguments.length||null===e||void 0===e)return[];if(Array.isArray(e)){var n=e.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(e){return t.utils.toString(e).toLowerCase()});var i=[];return n.forEach(function(e){var n=e.split(t.tokenizer.seperator);i=i.concat(n)},this),i}return e.toString().trim().toLowerCase().split(t.tokenizer.seperator)},t.tokenizer.defaultSeperator=/[\s\-]+/,t.tokenizer.seperator=t.tokenizer.defaultSeperator,t.tokenizer.setSeperator=function(e){null!==e&&void 0!==e&&"object"==typeof e&&(t.tokenizer.seperator=e)},t.tokenizer.resetSeperator=function(){t.tokenizer.seperator=t.tokenizer.defaultSeperator},t.tokenizer.getSeperator=function(){return t.tokenizer.seperator},t.Pipeline=function(){this._queue=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in t.Pipeline.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[n]=e},t.Pipeline.getRegisteredFunction=function(e){return e in t.Pipeline.registeredFunctions!=!0?null:t.Pipeline.registeredFunctions[e]},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.getRegisteredFunction(e);if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},t.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},t.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var i=null;null!=n&&(i=JSON.stringify(n));for(var o=new t.Configuration(i,this.getFields()).get(),r={},s=Object.keys(e),u=0;u14def path_split(path: str): +15 '''Used to split the standard Kepware address decimal notation into a dict that contains the +16 *channel*, *device* and *tag_path* keys. +17 +18 :param path: standard Kepware address in decimal notation ("ch1.dev1.tg1.tg2.tg3") +19 :return: dict that contains the "channel", "device" and "tag_path" +20 :rtype: dict 21 -22 return = {'channel': 'ch1', 'device': 'dev1', 'tag_path': ['tg1','tg2','tg3']} +22 Ex: path = "ch1.dev1.tg1.tg2.tg3" 23 -24 Ex: path = "ch1.dev1" +24 return = {'channel': 'ch1', 'device': 'dev1', 'tag_path': ['tg1','tg2','tg3']} 25 -26 return = {'channel': 'ch1', 'device': 'dev1'} -27 ''' -28 path_list = path.split('.', 2) -29 path_obj = {} -30 for x in range(0, len(path_list)): -31 if x == 0: -32 path_obj['channel'] = path_list[0] -33 elif x == 1: -34 path_obj['device'] = path_list[1] -35 else: -36 path_obj['tag_path'] = path_list[2].split('.') -37 return path_obj +26 Ex: path = "ch1.dev1" +27 +28 return = {'channel': 'ch1', 'device': 'dev1'} +29 ''' +30 path_list = path.split('.', 2) +31 path_obj = {} +32 for x in range(0, len(path_list)): +33 if x == 0: +34 path_obj['channel'] = path_list[0] +35 elif x == 1: +36 path_obj['device'] = path_list[1] +37 else: +38 path_obj['tag_path'] = path_list[2].split('.') +39 return path_obj0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e 1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();o Kepware Configuration API SDK for Python\n\n\n\n This is a package to help create Python applications to conduct operations with the Kepware Configuration API. This package is designed to work with all versions of Kepware that support the Configuration API including Thingworx Kepware Server (TKS), Thingworx Kepware Edge (TKE) and KEPServerEX (KEP).
\n\nPrerequisites
\n\nPackage supported and tested on Python 3.9 or later. Older versions support earlier Python 3 environments but have less functionality. All HTTP communication is handled by the urllib Python standard library.
\n\nFeatures
\n\n\n
\n\n- Supports both HTTP and HTTPS connections with certificate validation options
\nSDK allows for GET, ADD, DELETE, and MODIFY functions for the following Kepware configuration objects:
\n\n\n\n
\n\n\n \n\n\nFeatures \nTKS/KEP \nTKE \n\n \nProject Properties \n
(Get and Modify Only)Y \nY \n\n \nConnectivity \n
(Channel, Devices, Tags, Tag Groups)Y \nY \n\n \nIoT Gateway \n
(Agents, IoT Items)Y \nY \n\n \nDatalogger \n
(Log Groups, Items, Mapping, Triggers, Reset Mapping Service)Y \nY \n\n \nAdministration \n
(User Groups, Users, UA Endpoints, Local License Server)Y* \nY \n\n \n\nProduct Info and Health Status** \nY \nY \n\n
\n\n- Note (*) - UA Endpoints and Local License Server supported for Kepware Edge only
\n- Note (**) - Added to Kepware Server v6.13 / Kepware Edge v1.5 and later builds
\nDriver specific features:
\n\n\n\n
\n\n\n \n\n\nDriver \nFeatures \n\n \nGE Ethernet Global Data \nExchanges, Ranges and Name Resolutions \n\n \n\nUniversal Device Driver \nProfile Library \nMethods to read the following logs:
\n\n\n\n
\n\n\n \n\n\nLogs \nTKS/KEP \nTKE \n\n \nEvent Log \nY \nY \n\n \n\nAPI Transaction Log \nY \nY \nConfiguration API Services implemented:
\n\n\n\n
\n\n\n \n\n\nServices \nTKS/KEP \nTKE \n\n \nTagGeneration \n
(for supported drivers)Y \nY \n\n \nReinitializeRuntime \nY* \nY \n\n \n\nProjectLoad and ProjectSave \nY \nY \nNote (*) - Reinitialize service was implemented for Kepware Server v6.8+
\n\nFiltering, sorting and pagination query options are added for any collections methods (ex: get_all_devices() or get_all_channel()).
\n\nGeneric REST methods are provided to use for functions not developed in SDK package. These are found in the Server Class in connection.py
\n\nKnown Limitations
\n\n\n
\n\n- Other property configuration for more complex drivers with objects besides channels, devices, tags and tag groups are not always explicitly defined
\n- Other supported plug-ins (EFM Exporter, Scheduler, etc) are not defined
\n- When using hostnames (not IP addresses) for connections, delays may occur under certain network configurations as the connection may attempt IPv6 connections first. IPv6 is not supported by Kepware servers at this time.
\nInstallation
\n\nPackage can be installed with
\n\npipusing the following:\n\npip install kepconfig\nKey Concepts
\n\nNOTE: Detailed examples can also be found in the examples folder.
\n\nCreate server connection
\n\n\n\n\n\nimport kepconfig.connection\n\nserver = connection.server(host = '127.0.0.1', port = 57412, user = 'Administrator', pw = '')\n\n# For HTTPS connections:\nserver = connection.server(host = '127.0.0.1', port = 57512, user = 'Administrator', pw = '', https=True)\nFor certificate validation, the SDK uses the OS/systems trusted CA certificate store. The connection uses the \"create_default_context()\" function as part of urllib as described at the following links:
\n\n\n\nFor Windows OSes, the Kepware server's instance certificate can be loaded into the hosts \"Trusted Root Certificate Authorities\" store.
\n\nCreate an object
\n\nObjects such as channels or devices can be created either singularly or with children included.
\n\nEx: Add Single channel
\n\n\n\n\n\nfrom kepconfig.connectivity import channel\n\nchannel_data = {"common.ALLTYPES_NAME": "Channel1","servermain.MULTIPLE_TYPES_DEVICE_DRIVER": "Simulator"}\nresult = channel.add_channel(server,channel_data)\nEx: Add Multiple tags
\n\n\n\n\n\nfrom kepconfig.connectivity import tag\n\ntag_info = [\n {\n "common.ALLTYPES_NAME": "Temp",\n "servermain.TAG_ADDRESS": "R0"\n },\n {\n "common.ALLTYPES_NAME": "Temp2",\n "servermain.TAG_ADDRESS": "R1"\n }\n]\ntag_path = '{}.{}.{}'.format(ch_name, dev_name, tag_group_path)\nresult = tag.add_tag(server, tag_path, tag_info))\nNeed More Information
\n\nVisit:
\n\n\n
\n"}, {"fullname": "kepconfig.admin", "modulename": "kepconfig.admin", "kind": "module", "doc": "- Kepware.com
\n- PTC.com
\n\n"}, {"fullname": "kepconfig.admin.lls", "modulename": "kepconfig.admin.lls", "kind": "module", "doc": "
adminmodule provides functionality to manage Kepware Administration based \nproperties available through the Kepware Configuration API\n"}, {"fullname": "kepconfig.admin.lls.lls_config", "modulename": "kepconfig.admin.lls", "qualname": "lls_config", "kind": "class", "doc": "
llsexposes an API to allow modifications to Local License Server parameters in \nthe Kepware Administration through the Kepware Configuration APIA class to represent a admin properties for the Local License Server connection from an instance of Kepware. \nThis object is used to easily manage the LLS parameters for a Kepware instance.
\n\nParameters
\n\n\n
\n"}, {"fullname": "kepconfig.admin.lls.lls_config.__init__", "modulename": "kepconfig.admin.lls", "qualname": "lls_config.__init__", "kind": "function", "doc": "\n", "signature": "(config={})"}, {"fullname": "kepconfig.admin.lls.get_lls_config", "modulename": "kepconfig.admin.lls", "qualname": "get_lls_config", "kind": "function", "doc": "- server_name: Host name or IP address of the LLS server
\n- server_port: HTTP/non-SSL port to target for the LLS server
\n- check_period: Period that Kepware checks licensing status
\n- server_port_SSL: HTTPS/SSL port to target for the LLS server
\n- allow_insecure_comms: When True, use HTTP/non-SSL connection to LLS
\n- allow_self_signed_certs: Allow for self signed certificates to be used during HTTPS/SSL connections to the LLS
\n- instance_alias_name: Alias name for LLS to use as reference to this Kepware instance
\nReturns the properties of the Local License server connection properties. Returned object is
\n\nlls_configclass object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclassReturns
\n\n\n\n\n\n
lls_configclass object with lls connection configurationRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server) -> kepconfig.admin.lls.lls_config:", "funcdef": "def"}, {"fullname": "kepconfig.admin.lls.update_lls_config", "modulename": "kepconfig.admin.lls", "qualname": "update_lls_config", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nUpdates the Local License Server connection properties for Kepware.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- config:
\nlls_configclass object with lls connection configurationReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tconfig: kepconfig.admin.lls.lls_config) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.lls.enable_lls", "modulename": "kepconfig.admin.lls", "qualname": "enable_lls", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nEnables the Local License Server connection for Kepware.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclassReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.lls.disable_lls", "modulename": "kepconfig.admin.lls", "qualname": "disable_lls", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDisables the Local License Server connection for Kepware.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclassReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.lls.force_license_check", "modulename": "kepconfig.admin.lls", "qualname": "force_license_check", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes a ForceLicenseCheck service call to the Kepware instance. This triggers the server to verify the \nlicense state of the license received from the Local License Server.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, job_ttl: int = None):", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server", "modulename": "kepconfig.admin.ua_server", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.admin.ua_server.add_endpoint", "modulename": "kepconfig.admin.ua_server", "qualname": "add_endpoint", "kind": "function", "doc": "
ua_serverexposes an API to allow modifications (add, delete, modify) to \nOPC UA Server endpoints within the Kepware Administration through the Kepware Configuration APIAdd an
\n\n\"endpoint\"or multiple\"endpoint\"objects to Kepware UA Server by passing a \nlist of endpoints to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the UA Endpoints to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n endpoints added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server.del_endpoint", "modulename": "kepconfig.admin.ua_server", "qualname": "del_endpoint", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete an
\n\n\"endpoint\"object in Kepware UA ServerParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- endpoint: name of endpoint to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, endpoint: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server.modify_endpoint", "modulename": "kepconfig.admin.ua_server", "qualname": "modify_endpoint", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"endpoint\"object and it's properties in Kepware UA Server. If a\"endpoint\"is not provided as an input,\nyou need to identify the endpoint in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the endpoint that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the UA endpoint properties to be modified.
\n- endpoint: (optional) name of endpoint to modify. Only needed if not existing in
\n\"DATA\"Returns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\tendpoint: str = None) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server.get_endpoint", "modulename": "kepconfig.admin.ua_server", "qualname": "get_endpoint", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"endpoint\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- endpoint: name of endpoint to retrieve
\nReturns
\n\n\n\n\nDict of properties for the UA endpoint requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, endpoint: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server.get_all_endpoints", "modulename": "kepconfig.admin.ua_server", "qualname": "get_all_endpoints", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all
\n\n\"endpoint\"objects and their properties.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of UA endpoints. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize.
\nReturns
\n\n\n\n\nList of properties for all UA endpoints requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups", "modulename": "kepconfig.admin.user_groups", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.admin.user_groups.add_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "add_user_group", "kind": "function", "doc": "
user_groupsexposes an API to allow modifications (add, delete, modify) to \nuser groups within the Kepware Administration User Manager through the Kepware Configuration APIAdd a
\n\n\"user group\"or multiple\"user group\"objects to Kepware User Manager by passing a \nlist of user groups to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the user groups to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n endpoints added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.del_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "del_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"user group\"object in Kepware User ManagerParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user_group: name of user group to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.modify_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "modify_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"user group\"object and it's properties in Kepware User Manager. If a\"user group\"is not provided as an input,\nyou need to identify the user group in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the user group that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the user group properties to be modified.
\n- user_group: (optional) name of user group to modify. Only needed if not existing in
\n\"DATA\"Returns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tuser_group: str = None) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.get_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "get_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"user group\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user_group: name of user group to retrieve
\nReturns
\n\n\n\n\nDict of properties for the user group requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user_group: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.get_all_user_groups", "modulename": "kepconfig.admin.user_groups", "qualname": "get_all_user_groups", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all
\n\n\"user group\"objects and their properties.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of user groups. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize.
\nReturns
\n\n\n\n\nList of properties for all user groups
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.enable_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "enable_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nEnable the
\n\n\"user group\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user_group: name of user group
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.disable_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "disable_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDisable the
\n\n\"user group\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user_group: name of user group
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users", "modulename": "kepconfig.admin.users", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.admin.users.add_user", "modulename": "kepconfig.admin.users", "qualname": "add_user", "kind": "function", "doc": "
usersexposes an API to allow modifications (add, delete, modify) to \nusers within the Kepware Administration User Management through the Kepware Configuration APIAdd a
\n\n\"user\"or multiple\"user\"objects to Kepware User Manager by passing a \nlist of users to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the users to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n endpoints added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.del_user", "modulename": "kepconfig.admin.users", "qualname": "del_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"user\"object in Kepware User ManagerParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user: name of user to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.modify_user", "modulename": "kepconfig.admin.users", "qualname": "modify_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"user object\"and it's properties in Kepware User Manager. If a\"user\"is not provided as an input,\nyou need to identify the user in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the user that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the user properties to be modified.
\n- user: (optional) name of user to modify. Only needed if not existing in
\n\"DATA\"Returns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tuser: str = None) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.get_user", "modulename": "kepconfig.admin.users", "qualname": "get_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"user\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user: name of user to retrieve
\nReturns
\n\n\n\n\nDict of properties for the user requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.get_all_users", "modulename": "kepconfig.admin.users", "qualname": "get_all_users", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all
\n\n\"user\"objects and their properties.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of users. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize.
\nReturns
\n\n\n\n\nList of properties for all users
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.enable_user", "modulename": "kepconfig.admin.users", "qualname": "enable_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nEnable the
\n\n\"user\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user: name of user
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.disable_user", "modulename": "kepconfig.admin.users", "qualname": "disable_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDisable the
\n\n\"user\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user: name of user
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connection", "modulename": "kepconfig.connection", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connection.server", "modulename": "kepconfig.connection", "qualname": "server", "kind": "class", "doc": "
connectionexposes anserverclass that manages the connection\ninformation and RESTful requests for the Kepware Configuration API Library.A class to represent a connection to an instance of Kepware. This object is used to \ncreate the Authentication and server parameters to taget a Kepware instance. An instance of this is \nused in all configuration calls done.
\n\nParameters
\n\n\n
\n\n- host: host name or IP address
\n- port: port of Configuration API
\n- username: username to conduct \"Basic Authentication\"
\n- password: password to conduct \"Basic Authentication\"
\n- https: Sets
\nSSL_onto use HTTPS connection (Default: False)- SSL_on: Identify to use HTTPS connection (Default: False)
\n- SSL_ignore_hostname: During certificate validation ignore the hostname check
\n- SSL_trust_all_certs: (insecure) - During certificate validation trust any certificate - if True, \nwill \"set SSL_ignore_hostname\" to true
\n- url: base URL for the server connection
\nMethods
\n\n\n\n
reinitialize(): reinitialize the Kepware server\n\n
get_transaction_log(): retrieve the Configuration API transaction logs\n\n
get_event_log(): retrieve the Kepware Event Log\n\n
get_project_properties(): retrieve the Kepware Project Properties\n\n
modify_project_properties()- modify the Kepware Project Properties\n"}, {"fullname": "kepconfig.connection.server.__init__", "modulename": "kepconfig.connection", "qualname": "server.__init__", "kind": "function", "doc": "\n", "signature": "(host: str, port: int, user: str, pw: str, https: bool = False)"}, {"fullname": "kepconfig.connection.server.get_status", "modulename": "kepconfig.connection", "qualname": "server.get_status", "kind": "function", "doc": "
service_status()- retrive service job statusExecutes a health status request to the Kepware instance to report service statuses.
\n\nReturns
\n\n\n\n\nList of data for the health status request
\nRaises
\n\n\n
\n", "signature": "(self) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.get_info", "modulename": "kepconfig.connection", "qualname": "server.get_info", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nRequests product information from the Kepware instance. Provides various information including\nproduct name and version information.
\n\nReturns
\n\n\n\n\ndict of data for the product information request
\nRaises
\n\n\n
\n", "signature": "(self) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.reinitialize", "modulename": "kepconfig.connection", "qualname": "server.reinitialize", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes a Reinitialize service call to the Kepware instance.
\n\nParameters
\n\n\n
\n\n- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(self, job_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.get_transaction_log", "modulename": "kepconfig.connection", "qualname": "server.get_transaction_log", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\nGet the Transaction Log from the Kepware instance.
\n\nParameters
\n\n\n
\n\n- limit: (optional) number of transaction log entries to request
\n- start: (optional) start time of query as
\ndatetime.datetimetype and should be UTC- end: (optional) end time of query as
\ndatetime.datetimetype and should be UTCRaises
\n\n\n
\n", "signature": "(\tself,\tlimit: int = None,\tstart: datetime.datetime = None,\tend: datetime.datetime = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.get_event_log", "modulename": "kepconfig.connection", "qualname": "server.get_event_log", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nGet the Event Log from the Kepware instance.
\n\nParameters
\n\n\n
\n\n- limit: (optional) number of event log entries to request
\n- start: (optional) start time of query as
\ndatetime.datetimetype and should be UTC- end: (optional) end time of query as
\ndatetime.datetimetype and should be UTC- options: (optional) Dict of parameters to filter, sort or pagenate the list of transactions. Options are
\nevent, \nsortOrder,sortProperty,pageNumber, andpageSizeRaises
\n\n\n
\n", "signature": "(\tself,\tlimit: int = None,\tstart: datetime.datetime = None,\tend: datetime.datetime = None,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.get_project_properties", "modulename": "kepconfig.connection", "qualname": "server.get_project_properties", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nGet the Project Properties of the Kepware instance.
\n\nReturns
\n\n\n\n\nDict of all the project properties
\nRaises
\n\n\n
\n", "signature": "(self) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.modify_project_properties", "modulename": "kepconfig.connection", "qualname": "server.modify_project_properties", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify the Project Properties of the Kepware instance.
\n\nParameters
\n\n\n
\n\n- DATA: Dict of the project properties to be modified
\n- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(self, DATA: dict, force: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.save_project", "modulename": "kepconfig.connection", "qualname": "server.save_project", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes a ProjectSave Service call to the Kepware instance. This saves \na copy of the current project file to disk. The filename
\n\nParameters
\n\n\n
\n\n- \n
filename: Relative file path and name of project file including the file extension to save.\nLocation of relative project file paths:
\n\nTKS or KEP (Windows): C:\\PROGRAMDATA\\PTC\\Thingworx Kepware Server\\V6 or \n C:\\PROGRAMDATA\\Kepware\\KEPServerEX\\V6\nTKE (Linux): /opt/tkedge/v1/user_data\n- \n
password: (optional) Specify a password with which to save an encrypted project file with.
\nThis password will be required to load this project file.- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(\tself,\tfilename: str,\tpassword: str = None,\tjob_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.load_project", "modulename": "kepconfig.connection", "qualname": "server.load_project", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\nExecutes a ProjectLoad Service call to the Kepware instance. This loads \na project file to disk.
\n\nINPUTS:
\n\nParameters
\n\n\n
\n\n- \n
filename: Fully qualified or relative path and name of project file including the file extension. Absolute\npaths required for TKS and KEP while file path is relative for TKE:
\n\nWindows - filename = C:\\filepath\\test.opf\nLinux - filename = filepath/test.lpf - Location is /opt/tkedge/v1/user_data/filepath/test.lpf\n- \n
password: (optional) Specify a password with which to load an encrypted project file.
- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(\tself,\tfilename: str,\tpassword: str = None,\tjob_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.service_status", "modulename": "kepconfig.connection", "qualname": "server.service_status", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\nReturns the status of a service job. Used to verify if a service call\nhas completed or not.
\n\nParameters
\n\n\n
\n\n- resp:
\nKepServiceResponseinstance with job informationReturns
\n\n\n\n\n\n
KepServiceStatusinstance with job statusRaises
\n\n\n
\n", "signature": "(self, resp: kepconfig.structures.KepServiceResponse):", "funcdef": "def"}, {"fullname": "kepconfig.connectivity", "modulename": "kepconfig.connectivity", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n\n
connectivitymodule provides functionality to manage Kepware driver configuration \navailable through the Kepware Configuration API. This includes channels, devices, \ntags, tag groups and driver specific objects.Driver specific object support, if available, through their own modules. Currently\nthe GE Ethernet Global Data and Universal Device Drivers have driver specific API\nsupport in the SDK.
\n"}, {"fullname": "kepconfig.connectivity.channel", "modulename": "kepconfig.connectivity.channel", "kind": "module", "doc": "\n"}, {"fullname": "kepconfig.connectivity.channel.add_channel", "modulename": "kepconfig.connectivity.channel", "qualname": "add_channel", "kind": "function", "doc": "
channelexposes an API to allow modifications (add, delete, modify) to \nchannel objects within the Kepware Configuration APIAdd a
\n\n\"channel\"or multiple\"channel\"objects to Kepware. Can be used to pass children of a channel object \nsuch as devices and tags/tag groups. This allows you to create a channel, it's devices and tags \nall in one function, if desired.Additionally it can be used to pass a list of channels and it's children to be added all at once.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the channel and it's children\nexpected by Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n channels added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.del_channel", "modulename": "kepconfig.connectivity.channel", "qualname": "del_channel", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"channel\"object in Kepware. This will delete all children as wellParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel: name of channel
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, channel: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.modify_channel", "modulename": "kepconfig.connectivity.channel", "qualname": "modify_channel", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a channel object and it's properties in Kepware. If a
\n\n\"channel\"is not provided as an input,\nyou need to identify the channel in the 'common.ALLTYPES_NAME' property field in\"DATA\". It will \nassume that is the channel that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the
\nchannelproperties to be modified- channel: (optional) - name of channel to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tchannel: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.get_channel", "modulename": "kepconfig.connectivity.channel", "qualname": "get_channel", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the channel object.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel: name of channel
\nReturns
\n\n\n\n\nDict of data for the channel requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, channel: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.get_all_channels", "modulename": "kepconfig.connectivity.channel", "qualname": "get_all_channels", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all channel objects and their properties.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of channels. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSizeReturns
\n\n\n\n\nList of data for all channels in Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.get_channel_structure", "modulename": "kepconfig.connectivity.channel", "qualname": "get_channel_structure", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of
\n\n\"channel\"and includes all\"devices\"and the\"tag\"and\"tag group\"objects for a \nchannel in Kepware. Returned object is a dict of channel properties including a device list with \ntag lists and tag group lists.The returned object resembles the example below, nested based on how many \nlevels the tag_group namespace has tags or tag_groups:
\n\nExample return:
\n\n\n\n{\n channel_properties,\n 'devices: [\n {\n device1_properties,\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel: name of channel
\nReturns
\n\n\n\n\nDict of data for the channel structure requested for
\n\"channel\"Raises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, channel: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device", "modulename": "kepconfig.connectivity.device", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.device.add_device", "modulename": "kepconfig.connectivity.device", "qualname": "add_device", "kind": "function", "doc": "
deviceexposes an API to allow modifications (add, delete, modify) to \ndevice objects within the Kepware Configuration APIAdd a
\n\n\"device\"or multiple\"device\"objects to a channel in Kepware. Can be used to pass children of a device object \nsuch as tags and tag groups. This allows you to create a device and tags \nall in one function, if desired.Additionally it can be used to pass a list of devices and it's children to be added all at once.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel_name: channel to add the device object(s)
\n- DATA: Dict or List of Dicts of the device(s) and it's children\nexpected by Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n devices added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tchannel_name: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.del_device", "modulename": "kepconfig.connectivity.device", "qualname": "del_device", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"device\"object in Kepware. This will delete all children as well.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to delete. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"Returns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, device_path: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.modify_device", "modulename": "kepconfig.connectivity.device", "qualname": "modify_device", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a device object and it's properties in Kepware.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"- DATA: Dict of the
\ndeviceproperties to be modified- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tDATA: dict,\t*,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.get_device", "modulename": "kepconfig.connectivity.device", "qualname": "get_device", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the device object.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to retrieve properties. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"Returns
\n\n\n\n\nDict of data for the device requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, device_path: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.get_all_devices", "modulename": "kepconfig.connectivity.device", "qualname": "get_all_devices", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all device objects and their properties within a channel. Returned object is JSON list.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel: name of channel
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of devices. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSizeReturns
\n\n\n\n\nList of data for all devices within the channel
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tchannel_name: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.auto_tag_gen", "modulename": "kepconfig.connectivity.device", "qualname": "auto_tag_gen", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes Auto Tag Generation function on devices that support the feature in Kepware
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- \n
device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the \ndevice such as
\"channel1.device1\"- \n
job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
Returns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tjob_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.get_all_tags_tag_groups", "modulename": "kepconfig.connectivity.device", "qualname": "get_all_tags_tag_groups", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"tag\"and\"tag group\"objects for as specific\ndevice in Kepware. Returned object is a dict of tag list and tag group list.The returned object resembles the example below, nested based on how many \nlevels the tag_group namespace has tags or tag_groups:
\n\nExample return:
\n\n\n\n{\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"Returns
\n\n\n\n\nDict of data for the tag structure for device requested at
\n\"device_path\"locationRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, device_path: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.get_device_structure", "modulename": "kepconfig.connectivity.device", "qualname": "get_device_structure", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of
\n\n\"device\"and includes all\"tag\"and\"tag group\"objects for as specific\ndevice in Kepware. Returned object is a dict of device properties including a tag list and tag group list.The returned object resembles example below, nested based on how many \nlevels the tag_group namespace has tags or tag_groups:
\n\nExample return:
\n\n\n\n{\n device_properties,\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"Returns
\n\n\n\n\nDict of data for the device structure at
\n\"device_path\"locationRaises
\n\n\n
\n", "signature": "(server, device_path) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd", "modulename": "kepconfig.connectivity.egd", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.egd.exchange", "modulename": "kepconfig.connectivity.egd.exchange", "kind": "module", "doc": "
egdmodule provides support for GE EGD driver specific objects \nwithin the Kepware Configuration API\n"}, {"fullname": "kepconfig.connectivity.egd.exchange.add_exchange", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "add_exchange", "kind": "function", "doc": "
exchangeexposes an API to allow modifications (add, delete, modify) to \nexchange objects for EGD devices within the Kepware Configuration APIAdd a
\n\n\"exchange\"or multiple\"exchange\"objects to Kepware. Can be used to pass children of a exchange object \nsuch as ranges. This allows you to create a exchange and ranges for the exchange all in one function, if desired.Additionally it can be used to pass a list of exchanges and it's children to be added all at once.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- DATA: Dict or List of Dicts of the exchange(s) and it's children\nexpected by Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n exchanges added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.exchange.del_exchange", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "del_exchange", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete an
\n\n\"exchange\"object in Kepware. This will delete all children as wellParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.exchange.modify_exchange", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "modify_exchange", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"exchange\"object and it's properties in Kepware. If a\"exchange_name\"is not provided as an input,\nyou need to identify the exchange in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the exchange that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- DATA: Dict of the exchange properties to be modified.
\n- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: (optional) name of exchange to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\tDATA: dict,\t*,\texchange_name: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.exchange.get_exchange", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "get_exchange", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the exchange object or a list of all exchanges and their \nproperties for the type input. Returned object is JSON.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: (optional) name of exchange. If not defined, get all exchanges
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nDict of properties for the exchange requested or a List of exchanges and their properties
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str = None,\t*,\toptions: dict = None) -> Union[dict, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.exchange.get_all_exchanges", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "get_all_exchanges", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all
\n\n\"exchange\"objects (both CONSUMER and PRODUCER) and their properties. Returned object is JSON list.INPUTS:
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- options: (optional) Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nList - [list of consumer exchanges, list of producer exchanges] - list of lists for all \n exchanges for the device
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\t*,\toptions: dict = None) -> list[list, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.name", "modulename": "kepconfig.connectivity.egd.name", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.egd.name.add_name_resolution", "modulename": "kepconfig.connectivity.egd.name", "qualname": "add_name_resolution", "kind": "function", "doc": "
namesexposes an API to allow modifications (add, delete, modify) to \nname resolution objects for EGD devices within the Kepware Configuration APIAdd a
\n\n\"name resolution\"or multiple\"name resolution\"objects to Kepware. This allows you to \ncreate a name resolution or multiple name resolutions all in one function, if desired.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- DATA: Dict or List of Dicts of name resolutions\nexpected by Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n name resolutions added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.name.del_name_resolution", "modulename": "kepconfig.connectivity.egd.name", "qualname": "del_name_resolution", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"name resolution\"object in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- name: name of name resolution to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, device_path: str, name: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.name.modify_name_resolution", "modulename": "kepconfig.connectivity.egd.name", "qualname": "modify_name_resolution", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"name resolution\"object and it's properties in Kepware. If a\"name\"is not provided as an input,\nyou need to identify the name resolution in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the name resolution that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- DATA: Dict of name resolution properties to be modified
\n- name: (optional) name of name resolution to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tDATA: dict,\t*,\tname: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.name.get_name_resolution", "modulename": "kepconfig.connectivity.egd.name", "qualname": "get_name_resolution", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"name resolution\"object or a list of all name resolutions.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- DATA: Dict of name resolution properties to be modified
\n- name: (optional) name of name resolution to retrieve. If not defined, will get all name resolutions
\n- options: (optional) Dict of parameters to filter, sort or pagenate when getting a list of profiles. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSize. Only used when\"name\"is not defined.Returns
\n\n\n\n\nDict of the name resolution properties or List of Dicts for all name resolutions and their properties
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tname: str = None,\t*,\toptions: dict = None) -> Union[dict, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.range", "modulename": "kepconfig.connectivity.egd.range", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.egd.range.add_range", "modulename": "kepconfig.connectivity.egd.range", "qualname": "add_range", "kind": "function", "doc": "
rangesexposes an API to allow modifications (add, delete, modify) to \nrange objects in exchanges for EGD devices within the Kepware Configuration APIAdd a
\n\n\"range\"or multiple\"range\"objects to Kepware. This allows you to \ncreate a range or multiple ranges all in one function, if desired.When passing multiple ranges, they will be populated in the same order\nin the list sent. Ensure you provide the list in the order desired.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange that range is located
\n- DATA: Dict or List of Dicts of the range(s) to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n ranges added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.range.del_range", "modulename": "kepconfig.connectivity.egd.range", "qualname": "del_range", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"range\"object in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange that range is located
\n- range_name: name of range to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str,\trange_name: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.range.modify_range", "modulename": "kepconfig.connectivity.egd.range", "qualname": "modify_range", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"range\"object and it's properties in Kepware. If a\"range_name\"is not provided as an input,\nyou need to identify the range in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the range that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange that range is located
\n- DATA: Dict of the range properties to be modified.
\n- range_name: (optional) name of range to to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str,\tDATA: dict,\t*,\trange_name: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.range.get_range", "modulename": "kepconfig.connectivity.egd.range", "qualname": "get_range", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"range\"object or a list of all ranges.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange that range is located
\n- DATA: Dict of the range properties to be modified.
\n- range_name: (optional) name of range to retrieve. If not defined, get all ranges
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when range_name is not defined.
\nReturns
\n\n\n\n\nDict of properties for the range requested or a List of ranges and their properties
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str,\trange_name: str = None,\t*,\toptions: dict = None) -> Union[dict, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag", "modulename": "kepconfig.connectivity.tag", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.tag.add_tag", "modulename": "kepconfig.connectivity.tag", "qualname": "add_tag", "kind": "function", "doc": "
tagexposes an API to allow modifications (add, delete, modify) to \ntag and tag group objects within the Kepware Configuration APIAdd
\n\n\"tag\"or multiple\"tag\"objects to a specific path in Kepware. \nCan be used to pass a list of tags to be added at one path location.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying where to add tag(s). Standard Kepware address decimal \nnotation string that tags exists such as \"channel1.device1.tag_group1\" or \"channel1.device1\"
\n- DATA: Dict or List of Dicts of the tag(s) to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n tags added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\ttag_path: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.add_tag_group", "modulename": "kepconfig.connectivity.tag", "qualname": "add_tag_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nAdd
\n\n\"tag_group\"or multiple\"tag_group\"objects to a specific path in Kepware. \nCan be used to pass a list of tag_groups and children (tags or tag groups) to be added at one \npath location.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying where to add tag group(s). Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\" or \"channel1.device1\"
\n- DATA: Dict or List of Dicts of the tag group(s) to add and it's children (tags or tag groups)
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n tag groups added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\ttag_group_path: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.add_all_tags", "modulename": "kepconfig.connectivity.tag", "qualname": "add_all_tags", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nAdd
\n\n\"tag\"and\"tag group\"objects to a device in Kepware. To be used to \npass a list of tags, tag groups and/or children of tag groups (tags and tag \ngroups) to be added at once. See example below for required structure with \n\"tags\" and \"tag_groups\" as keys:Example DATA:
\n\n\n\n{\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- ch_dev_path: device path identifying where to add tags and tag groups. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1\"
\n- DATA: Dict of the tags and tag groups to add and it's children (tags or tag groups).
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nList [tag failure list, tag group failure list] - If a \"HTTP 207 - Multi-Status\" is received from \n Kepware for either tags or tag groups, a list of dict error responses for all tags and/or tag groups added that failed.
\nReturns
\n\n\n\n\nFalse - If tags or tag groups are not found in DATA
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tch_dev_path: str,\tDATA: dict) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.modify_tag", "modulename": "kepconfig.connectivity.tag", "qualname": "modify_tag", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"tag\"object and it's properties in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- full_tag_path: path identifying location and tag to modify. Standard Kepware address decimal \nnotation string including the tag such as \"channel1.device1.tag_group1.tag1\"
\n- DATA: Dict of the
\ntagproperties to be modified- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tfull_tag_path: str,\tDATA: dict,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.modify_tag_group", "modulename": "kepconfig.connectivity.tag", "qualname": "modify_tag_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"tag group\"object and it's properties in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying location and tag group to modify. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\"
\n- DATA: Dict of the
\ntag groupproperties to be modified- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\ttag_group_path: str,\tDATA: dict,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.del_tag", "modulename": "kepconfig.connectivity.tag", "qualname": "del_tag", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete
\n\n\"tag\"object at a specific path in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- full_tag_path: path identifying location and tag to delete. Standard Kepware address decimal \nnotation string including the tag such as \"channel1.device1.tag_group1.tag1\"
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, full_tag_path: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.del_tag_group", "modulename": "kepconfig.connectivity.tag", "qualname": "del_tag_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete
\n\n\"tag group\"object at a specific path in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying location and tag group to delete. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\"
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, tag_group_path: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_tag", "modulename": "kepconfig.connectivity.tag", "qualname": "get_tag", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"tag\"object at a specific path in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- full_tag_path: path identifying location and tag to delete. Standard Kepware address decimal \nnotation string including the tag such as \"channel1.device1.tag_group1.tag1\"
\nReturns
\n\n\n\n\nDict of data for the tag requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, full_tag_path: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_all_tags", "modulename": "kepconfig.connectivity.tag", "qualname": "get_all_tags", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"tag\"object at a specific path in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- full_tag_path: path identifying location to retreive tag list. Standard Kepware address decimal \nnotation string including the tag such as \"channel1.device1.tag_group1.tag1\"
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of tags. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSizeReturns
\n\n\n\n\nList of data for all tags
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tfull_tag_path: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_tag_group", "modulename": "kepconfig.connectivity.tag", "qualname": "get_tag_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the \"tag group\" object at a specific \npath in Kepware. Returned object is JSON.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying location and tag group to retrieve properties. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\"
\nReturns
\n\n\n\n\nDict of data for the tag group requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, tag_group_path: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_all_tag_groups", "modulename": "kepconfig.connectivity.tag", "qualname": "get_all_tag_groups", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"tag group\"objects at a specific \npath in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying location to retrieve tag group list and properties. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\"
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of devices. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSizeReturns
\n\n\n\n\nList of data for all tag groups
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\ttag_group_path: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_full_tag_structure", "modulename": "kepconfig.connectivity.tag", "qualname": "get_full_tag_structure", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"tag\"and\"tag group\"objects at a specific \npath in Kepware. Returned object is a dict of tag list and tag group list.Example:
\n\n\n\n{\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[tag_group1_dict, tag_group2_dict,...]\n}\nIf
\n\nrecursiveis TRUE, then the call will iterate through all tag groups and get the tags and \ntag groups of all tag group children.This would be the equivilant of asking for all tags and tag groups\nthat exist below the\"path\"location. The returned object would look like below, nested based on how many \nlevels the tag_group namespace has tags or tag_groups:Example with Recursive True:
\n\n\n\n{\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- path: path identifying location to retreive the tag structure. Standard Kepware address decimal \nnotation string such as \"channel1.device1.tag_group1\" and must container at least the channel and device.
\n- recursive: (optional) If True, returns structures within the tag groups found and all of their \nchildren. (default= False)
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of tags and tag groups. \nOptions are 'filter', 'sortOrder', and 'sortProperty' only.
\nReturns
\n\n\n\n\nDict of data for the tag structure requested at \"path\" location
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tpath: str,\t*,\trecursive: bool = False,\toptions: dict = None) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd", "modulename": "kepconfig.connectivity.udd", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.udd.profile", "modulename": "kepconfig.connectivity.udd.profile", "kind": "module", "doc": "
uddmodule provides support for Universal Device driver specific objects \nwithin the Kepware Configuration API\n"}, {"fullname": "kepconfig.connectivity.udd.profile.add_profile", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "add_profile", "kind": "function", "doc": "
profileexposes an API to allow modifications (add, delete, modify) to \nprofile objects for the UDD Profile Library plug-in within the Kepware Configuration APIAdd a
\n\n\"profile\"or a list of\"profile\"objects to the UDD Profile Library plug-in for Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the profiles to add to the Profile Library \nthrough Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n profiles added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd.profile.del_profile", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "del_profile", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"profile\"object in UDD Profile Library plug-in for Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- profile_name: name of profile
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, profile_name: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd.profile.modify_profile", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "modify_profile", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"profile\"object and it's properties in Kepware. If a\"profile_name\"is not provided as an input,\nyou need to identify the profile in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the profile that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the profile properties to be modified.
\n- profile_name: (optional) name of profile to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\tprofile_name: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd.profile.get_profile", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "get_profile", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the profile object or a list of all profiles and their \nproperties. Will return a list if
\n\n\"profile_name\"is not provided.INPUTS:
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- profile_name: (optional) name of profile. If not defined, will get all profiles
\n- options: (optional) Dict of parameters to filter, sort or pagenate when getting a list of profiles. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSize. Only used when profile_name is not defined.Returns
\n\n\n\n\nDict of the profile properties or List of Dicts for all profiles and their properties in the Profile Library
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tprofile_name: str = None,\t*,\toptions: dict = None) -> Union[dict, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd.profile.get_all_profiles", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "get_all_profiles", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all profile objects and their properties. Returned object is JSON list.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate when getting a list of profiles. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSize. Only used when profile_name is not defined.Returns
\n\n\n\n\nList of data for all profiles and their properties in the Profile Library
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None):", "funcdef": "def"}, {"fullname": "kepconfig.datalogger", "modulename": "kepconfig.datalogger", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.datalogger.log_group", "modulename": "kepconfig.datalogger.log_group", "kind": "module", "doc": "
dataloggermodule provides support for Kepware's Datalogger plug-in specific objects \nwithin the Kepware Configuration API\n"}, {"fullname": "kepconfig.datalogger.log_group.add_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "add_log_group", "kind": "function", "doc": "
log_groupexposes an API to allow modifications (add, delete, modify) to \nlog group objects in DataLogger within the Kepware Configuration APIAdd a
\n\n\"log group\"or multiple\"log groups\"objects to Kepware's DataLogger. It can be used \nto pass a list of log groups to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or a list of the log groups to add through Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n log groups added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.del_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "del_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"log group\"object in Kepware's Datalogger.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, log_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.modify_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "modify_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"log group\"object and it's properties in Kepware's Datalogger. If a\"log group\"is not provided as an input,\nyou need to identify the log group in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the log group that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the log group properties to be modified.
\n- log_group: (optional) name of log group to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tlog_group: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.get_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "get_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"log group\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to retrieve
\nReturns
\n\n\n\n\nDict of properties for the log group requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, log_group: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.get_all_log_groups", "modulename": "kepconfig.datalogger.log_group", "qualname": "get_all_log_groups", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all log group objects for Kepware's Datalogger. Returned object is JSON list.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all log groups requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.enable_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "enable_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nEnable the
\n\n\"log group\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to enable
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, log_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.disable_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "disable_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDisable the log group. Returned object is JSON.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to enable
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, log_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.reset_column_mapping_service", "modulename": "kepconfig.datalogger.log_group", "qualname": "reset_column_mapping_service", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes a ResetColumnMapping serivce call to the log group
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to enable
\n- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tjob_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items", "modulename": "kepconfig.datalogger.log_items", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.datalogger.log_items.add_log_item", "modulename": "kepconfig.datalogger.log_items", "qualname": "add_log_item", "kind": "function", "doc": "
log_itemsexposes an API to allow modifications (add, delete, modify) to \nlog item (tag) objects in a Datalogger log group within the Kepware Configuration APIAdd a
\n\n\"log item\"or multiple\"log item\"objects to a log group in Kepware's Datalogger. It can \nbe used to pass a list of log items to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that the log items will be added
\n- DATA: Dict or a list of the log items to add through Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n log items added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items.del_log_item", "modulename": "kepconfig.datalogger.log_items", "qualname": "del_log_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"log item\"object of a log group in Kepware's Datalogger.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that log item exists
\n- log_item: name of log item to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tlog_item: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items.modify_log_item", "modulename": "kepconfig.datalogger.log_items", "qualname": "modify_log_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"log_item\"object and it's properties in Kepware. If a\"log_item\"is not provided as an input,\nyou need to identify the log_item in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the log_item that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that log item exists
\n- DATA: Dict of the log item properties to be modified.
\n- log_item: (optional) name of log item to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: dict,\t*,\tlog_item: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items.get_log_item", "modulename": "kepconfig.datalogger.log_items", "qualname": "get_log_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"log item\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that log item exists
\n- log_item: name of log item to retrieve
\nReturns
\n\n\n\n\nDict of properties for the log group requested
\nRaises
\n\n\n
\n", "signature": "(server, log_group, log_item) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items.get_all_log_items", "modulename": "kepconfig.datalogger.log_items", "qualname": "get_all_log_items", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"log item\"objects for a log group.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that log item exists
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all log items in the log group requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.mapping", "modulename": "kepconfig.datalogger.mapping", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.datalogger.mapping.modify_mapping", "modulename": "kepconfig.datalogger.mapping", "qualname": "modify_mapping", "kind": "function", "doc": "
mappingexposes an API to allow modifications (add, delete, modify) to \ncolumn mapping objects in a Datalogger log group within the Kepware Configuration APIModify a column
\n\n\"mapping\"object and it's properties in Kepware. If a\"mapping\"is not provided as an input,\nyou need to identify the column mapping in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the column mapping that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the mapping
\n- DATA: Dict of the mapping properties to be modified.
\n- mapping: (optional) column mapping to modify in the log group. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: dict,\t*,\tmapping: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.mapping.get_mapping", "modulename": "kepconfig.datalogger.mapping", "qualname": "get_mapping", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"mapping\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the mapping
\n- mapping: name of column mapping to retrieve properties
\nReturns
\n\n\n\n\nDict of properties for the mapping object requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tmapping: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.mapping.get_all_mappings", "modulename": "kepconfig.datalogger.mapping", "qualname": "get_all_mappings", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all column
\n\n\"mapping\"objects for a log group.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the mapping
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of mapping items. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all mapping items in the log group requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers", "modulename": "kepconfig.datalogger.triggers", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.datalogger.triggers.add_trigger", "modulename": "kepconfig.datalogger.triggers", "qualname": "add_trigger", "kind": "function", "doc": "
triggersexposes an API to allow modifications (add, delete, modify) to \ntrigger objects in a Datalogger log group within the Kepware Configuration APIAdd a
\n\n\"trigger\"or multiple\"trigger\"objects to a log group in Kepware's Datalogger. It can \nbe used to pass a list of triggers to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\n- DATA: Dict or a list of the trigger items to add through Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n triggers added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers.del_trigger", "modulename": "kepconfig.datalogger.triggers", "qualname": "del_trigger", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"trigger\"object of a log group in Kepware's Datalogger.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\n- trigger: name of trigger to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\ttrigger: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers.modify_trigger", "modulename": "kepconfig.datalogger.triggers", "qualname": "modify_trigger", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"trigger\"object and it's properties in Kepware. If a\"trigger\"is not provided as an input,\nyou need to identify the trigger in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the trigger that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\n- DATA: Dict of the trigger properties to be modified.
\n- trigger: (optional) name of trigger to modify in the log group. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: dict,\t*,\ttrigger: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers.get_trigger", "modulename": "kepconfig.datalogger.triggers", "qualname": "get_trigger", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"trigger\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\n- trigger: name of trigger to retrieve
\nReturns
\n\n\n\n\nDict of properties for the trigger requested
\nRaises
\n\n\n
\n", "signature": "(server, log_group, trigger) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers.get_all_triggers", "modulename": "kepconfig.datalogger.triggers", "qualname": "get_all_triggers", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"trigger\"objects for a log group.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\nReturns
\n\n\n\n\nDict of properties for the trigger requested
\nRaises
\n\n\n
\n\n- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of triggers. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all triggers in the log group requested
\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.error", "modulename": "kepconfig.error", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.error.KepError", "modulename": "kepconfig.error", "qualname": "KepError", "kind": "class", "doc": "
errorException classes raised by Kepconfig.\nIncludes KepError, KepURLError and KepHTTPErrorGeneral Exception class for Kepconfig.
\n\nParameters
\n\n\n
\n", "bases": "builtins.Exception"}, {"fullname": "kepconfig.error.KepError.__init__", "modulename": "kepconfig.error", "qualname": "KepError.__init__", "kind": "function", "doc": "\n", "signature": "(msg)"}, {"fullname": "kepconfig.error.KepURLError", "modulename": "kepconfig.error", "qualname": "KepURLError", "kind": "class", "doc": "- msg: General error message returned in string format.
\nException class raised by Kepconfig that derives responses from the urllib URLError exceptions.
\n\nParameters
\n\n\n
\n", "bases": "KepError"}, {"fullname": "kepconfig.error.KepURLError.__init__", "modulename": "kepconfig.error", "qualname": "KepURLError.__init__", "kind": "function", "doc": "\n", "signature": "(url=None, *args, **kwargs)"}, {"fullname": "kepconfig.error.KepHTTPError", "modulename": "kepconfig.error", "qualname": "KepHTTPError", "kind": "class", "doc": "- url: full url path of the request that flagged a URLError exception
\n- msg: reason parameter in URLError exception
\nException class raised by Kepconfig that derives responses from the urllib HTTPError \nexceptions. This exception class is also a valid HTTP response instance. It behaves \nthis way because HTTP protocol errors are valid responses, with a status \ncode, headers, and a body. In some contexts, an application may want to \nhandle an exception like a regular response.
\n\nParameters
\n\n\n
\n", "bases": "KepError"}, {"fullname": "kepconfig.error.KepHTTPError.__init__", "modulename": "kepconfig.error", "qualname": "KepHTTPError.__init__", "kind": "function", "doc": "\n", "signature": "(url=None, code=None, hdrs=None, payload=None, *args, **kwargs)"}, {"fullname": "kepconfig.iot_gateway", "modulename": "kepconfig.iot_gateway", "kind": "module", "doc": "- url: url parameter in HTTPError exception
\n- code: HTTP response code parameter in HTTPError exception
\n- hdrs: hdrs parameter in HTTPError exception
\n- payload: string of HTTP response payload that flagged HTTPError exception
\n- msg: msg parameter in HTTPError exception
\n\n"}, {"fullname": "kepconfig.iot_gateway.agent", "modulename": "kepconfig.iot_gateway.agent", "kind": "module", "doc": "
iot_gatewaymodule provides support for Kepware's IoT Gateway plug-in \nspecific objects within the Kepware Configuration API\n"}, {"fullname": "kepconfig.iot_gateway.agent.add_iot_agent", "modulename": "kepconfig.iot_gateway.agent", "qualname": "add_iot_agent", "kind": "function", "doc": "
agentexposes an API to allow modifications (add, delete, modify) to \nIot Gateway agent objects within the Kepware Configuration APIAdd a
\n\n\"agent\"or multiple\"agent\"objects of a specific type to Kepware's IoT Gateway. Can be used to pass children of an\nagent object such as iot items. This allows you to create an agent and iot items if desired. Multiple Agents need to be of the \nsame type.Additionally it can be used to pass a list of agents and it's children to be added all at once.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the agent and it's children\nexpected by Kepware Configuration API
\n- agent_type: (optional) agent type to add to IoT Gateway. Only needed if not existing in
\n\"DATA\". Valid values are \nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n iot agents added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list],\tagent_type: str = None) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.agent.del_iot_agent", "modulename": "kepconfig.iot_gateway.agent", "qualname": "del_iot_agent", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"agent\"object in Kepware. This will delete all children as wellParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- agent: name of IoT Agent to delete
\n- agent_type: (optional) agent type to delete in IoT Gateway. Valid values are \n
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, agent: str, agent_type: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.agent.modify_iot_agent", "modulename": "kepconfig.iot_gateway.agent", "qualname": "modify_iot_agent", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"agent\"object and it's properties in Kepware. If a\"agent\"is not provided as an input,\nyou need to identify the agent in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the agent that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the iot agent properties to be modified.
\n- agent: (optional) name of IoT agent to modify. Only needed if not existing in
\n\"DATA\"- agent_type: (optional) agent type to modify. Only needed if not existing in
\n\"DATA\". Valid values are \nMQTT Client,REST ClientorREST Server- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tagent: str = None,\tagent_type: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.agent.get_iot_agent", "modulename": "kepconfig.iot_gateway.agent", "qualname": "get_iot_agent", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"agent\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the iot agent properties to be modified.
\n- agent: name of IoT agent to retrieve
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nDict of properties for the iot agent requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, agent: str, agent_type: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.agent.get_all_iot_agents", "modulename": "kepconfig.iot_gateway.agent", "qualname": "get_all_iot_agents", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"agent\"objects for a specific agent type. Returned object is JSON list.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST Server- options: (optional) Dict of parameters to filter, sort or pagenate the list of IoT agents. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all IoT agents requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tagent_type: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items", "modulename": "kepconfig.iot_gateway.iot_items", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.iot_gateway.iot_items.add_iot_item", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "add_iot_item", "kind": "function", "doc": "
iot_itemsexposes an API to allow modifications (add, delete, modify) to \niot_items objects within the Kepware Configuration APIAdd a
\n\n\"iot item\"or multiple\"iot item\"objects to Kepware's IoT Gateway agent. Additionally \nit can be used to pass a list of iot items to be added to an agent all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the iot item or list of items\nexpected by Kepware Configuration API
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n iot items added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list],\tagent: str,\tagent_type: str) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items.del_iot_item", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "del_iot_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete an
\n\n\"iot item\"object in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- iot_item: IoT item to delete
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tiot_item: str,\tagent: str,\tagent_type: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items.modify_iot_item", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "modify_iot_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify an
\n\n\"iot item\"object and it's properties in Kepware. If a\"iot item\"is not provided as an input,\nyou need to identify the iot item in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the iot item that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the iot item properties to be modified.
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST Server- iot_item: (optional) name of IoT item to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\tagent: str,\tagent_type: str,\t*,\tiot_item: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items.get_iot_item", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "get_iot_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"iot item\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- iot_item: name of IoT item to retrieve properties
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nDict of properties for the iot item requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tiot_item: str,\tagent: str,\tagent_type: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items.get_all_iot_items", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "get_all_iot_items", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"iot item\"objects for an agent.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- iot_item: name of IoT item to retrieve properties
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST Server- options: (optional) Dict of parameters to filter, sort or pagenate the list of IoT items. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all IoT items
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tagent: str,\tagent_type: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.structures", "modulename": "kepconfig.structures", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.structures.KepServiceResponse", "modulename": "kepconfig.structures", "qualname": "KepServiceResponse", "kind": "class", "doc": "
structuresprovides general data structures to help manage \nvarious objects for Kepware's configurationA class to represent a return object when calling a \"service\" API of Kepware. This is\nused to return the responses when a \"service\" is executed appropriately
\n\nParameters
\n\n\n
\n"}, {"fullname": "kepconfig.structures.KepServiceResponse.__init__", "modulename": "kepconfig.structures", "qualname": "KepServiceResponse.__init__", "kind": "function", "doc": "\n", "signature": "(code: str = '', message: str = '', href: str = '')"}, {"fullname": "kepconfig.structures.KepServiceStatus", "modulename": "kepconfig.structures", "qualname": "KepServiceStatus", "kind": "class", "doc": "- \n
code: HTTP code returned
- \n
message: return from the \"service\" call
- \n
href: URL reference to the JOB that is created by the service API
A class to represent a status object when checking on a \"service\" API job state in Kepware. This is\nused to return the status of a \"service\" job
\n\nParameters
\n\n\n
\n"}, {"fullname": "kepconfig.structures.KepServiceStatus.__init__", "modulename": "kepconfig.structures", "qualname": "KepServiceStatus.__init__", "kind": "function", "doc": "\n", "signature": "(complete: str = '', status: str = '', message: str = '')"}, {"fullname": "kepconfig.utils", "modulename": "kepconfig.utils", "kind": "module", "doc": "- \n
complete: Boolean of service job completion status
- \n
status: Status code of job
- \n
message: Error message if service job fails
\n"}, {"fullname": "kepconfig.utils.path_split", "modulename": "kepconfig.utils", "qualname": "path_split", "kind": "function", "doc": "
utilsprovides general utilities to help manage \nvarious objects for Kepware's configurationUsed to split the standard Kepware address decimal notation into a dict that contains the \nchannel, device and tag_path keys.
\n\nParameters
\n\n\n
\n\n- path: standard Kepware address in decimal notation (\"ch1.dev1.tg1.tg2.tg3\")
\nReturns
\n\n\n\n\ndict that contains the \"channel\", \"device\" and \"tag_path\"
\nEx: path = \"ch1.dev1.tg1.tg2.tg3\"
\n\nreturn = {'channel': 'ch1', 'device': 'dev1', 'tag_path': ['tg1','tg2','tg3']}
\n\nEx: path = \"ch1.dev1\"
\n\nreturn = {'channel': 'ch1', 'device': 'dev1'}
\n", "signature": "(path: str):", "funcdef": "def"}]; + /** pdoc search index */const docs = [{"fullname": "kepconfig", "modulename": "kepconfig", "kind": "module", "doc": "Kepware Configuration API SDK for Python
\n\n\n\nThis is a package to help create Python applications to conduct operations with the Kepware Configuration API. This package is designed to work with all versions of Kepware that support the Configuration API including Thingworx Kepware Server (TKS), Thingworx Kepware Edge (TKE) and KEPServerEX (KEP).
\n\nAPI reference documentation is available on Github Pages
\n\nPrerequisites
\n\nPackage supported and tested on Python 3.9 or later. Older versions support earlier Python 3 environments but have less functionality. All HTTP communication is handled by the urllib Python standard library.
\n\nFeatures
\n\n\n
\n\n- Supports both HTTP and HTTPS connections with certificate validation options
\nSDK allows for GET, ADD, DELETE, and MODIFY functions for the following Kepware configuration objects:
\n\n\n\n
\n\n\n \n\n\nFeatures \nTKS/KEP \nTKE \n\n \nProject Properties \n
(Get and Modify Only)Y \nY \n\n \nConnectivity \n
(Channel, Devices, Tags, Tag Groups)Y \nY \n\n \nIoT Gateway \n
(Agents, IoT Items)Y \nY \n\n \nDatalogger \n
(Log Groups, Items, Mapping, Triggers, Reset Mapping Service)Y \nY \n\n \nAdministration \n
(User Groups, Users, UA Endpoints, Local License Server)Y* \nY \n\n \n\nProduct Info and Health Status** \nY \nY \n\n
\n\n- Note (*) - UA Endpoints and Local License Server supported for Kepware Edge only
\n- Note (**) - Added to Kepware Server v6.13 / Kepware Edge v1.5 and later builds
\nDriver specific features:
\n\n\n\n
\n\n\n \n\n\nDriver \nFeatures \n\n \nGE Ethernet Global Data \nExchanges, Ranges and Name Resolutions \n\n \n\nUniversal Device Driver \nProfile Library \nMethods to read the following logs:
\n\n\n\n
\n\n\n \n\n\nLogs \nTKS/KEP \nTKE \n\n \nEvent Log \nY \nY \n\n \n\nAPI Transaction Log \nY \nY \nConfiguration API Services implemented:
\n\n\n\n
\n\n\n \n\n\nServices \nTKS/KEP \nTKE \n\n \nTagGeneration \n
(for supported drivers)Y \nY \n\n \nReinitializeRuntime \nY* \nY \n\n \n\nProjectLoad and ProjectSave \nY \nY \nNote (*) - Reinitialize service was implemented for Kepware Server v6.8+
\n\nFiltering, sorting and pagination query options are added for any collections methods (ex: get_all_devices() or get_all_channel()).
\n\nGeneric REST methods are provided to use for functions not developed in SDK package. These are found in the Server Class in connection.py
\n\nKnown Limitations
\n\n\n
\n\n- Other property configuration for more complex drivers with objects besides channels, devices, tags and tag groups are not always explicitly defined
\n- Other supported plug-ins (EFM Exporter, Scheduler, etc) are not defined
\n- When using hostnames (not IP addresses) for connections, delays may occur under certain network configurations as the connection may attempt IPv6 connections first. IPv6 is not supported by Kepware servers at this time.
\nInstallation
\n\nPackage can be installed with
\n\npipusing the following:\n\npip install kepconfig\nKey Concepts
\n\nNOTE: Detailed examples can also be found in the examples folder.
\n\nCreate server connection
\n\n\n\n\n\nimport kepconfig.connection\n\nserver = connection.server(host = '127.0.0.1', port = 57412, user = 'Administrator', pw = '')\n\n# For HTTPS connections:\nserver = connection.server(host = '127.0.0.1', port = 57512, user = 'Administrator', pw = '', https=True)\nFor certificate validation, the SDK uses the OS/systems trusted CA certificate store. The connection uses the \"create_default_context()\" function as part of urllib as described at the following links:
\n\n\n\nFor Windows OSes, the Kepware server's instance certificate can be loaded into the hosts \"Trusted Root Certificate Authorities\" store.
\n\nCreate an object
\n\nObjects such as channels or devices can be created either singularly or with children included.
\n\nEx: Add Single channel
\n\n\n\n\n\nfrom kepconfig.connectivity import channel\n\nchannel_data = {"common.ALLTYPES_NAME": "Channel1","servermain.MULTIPLE_TYPES_DEVICE_DRIVER": "Simulator"}\nresult = channel.add_channel(server,channel_data)\nEx: Add Multiple tags
\n\n\n\n\n\nfrom kepconfig.connectivity import tag\n\ntag_info = [\n {\n "common.ALLTYPES_NAME": "Temp",\n "servermain.TAG_ADDRESS": "R0"\n },\n {\n "common.ALLTYPES_NAME": "Temp2",\n "servermain.TAG_ADDRESS": "R1"\n }\n]\ntag_path = '{}.{}.{}'.format(ch_name, dev_name, tag_group_path)\nresult = tag.add_tag(server, tag_path, tag_info))\nNeed More Information
\n\nVisit:
\n\n\n
\n"}, {"fullname": "kepconfig.admin", "modulename": "kepconfig.admin", "kind": "module", "doc": "- Kepware.com
\n- PTC.com
\n\n"}, {"fullname": "kepconfig.admin.lls", "modulename": "kepconfig.admin.lls", "kind": "module", "doc": "
adminmodule provides functionality to manage Kepware Administration based \nproperties available through the Kepware Configuration API\n"}, {"fullname": "kepconfig.admin.lls.lls_config", "modulename": "kepconfig.admin.lls", "qualname": "lls_config", "kind": "class", "doc": "
llsexposes an API to allow modifications to Local License Server parameters in \nthe Kepware Administration through the Kepware Configuration APIA class to represent a admin properties for the Local License Server connection from an instance of Kepware. \nThis object is used to easily manage the LLS parameters for a Kepware instance.
\n\nParameters
\n\n\n
\n"}, {"fullname": "kepconfig.admin.lls.lls_config.__init__", "modulename": "kepconfig.admin.lls", "qualname": "lls_config.__init__", "kind": "function", "doc": "\n", "signature": "(config={})"}, {"fullname": "kepconfig.admin.lls.get_lls_config", "modulename": "kepconfig.admin.lls", "qualname": "get_lls_config", "kind": "function", "doc": "- server_name: Host name or IP address of the LLS server
\n- server_port: HTTP/non-SSL port to target for the LLS server
\n- check_period: Period that Kepware checks licensing status
\n- server_port_SSL: HTTPS/SSL port to target for the LLS server
\n- allow_insecure_comms: When True, use HTTP/non-SSL connection to LLS
\n- allow_self_signed_certs: Allow for self signed certificates to be used during HTTPS/SSL connections to the LLS
\n- instance_alias_name: Alias name for LLS to use as reference to this Kepware instance
\nReturns the properties of the Local License server connection properties. Returned object is
\n\nlls_configclass object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclassReturns
\n\n\n\n\n\n
lls_configclass object with lls connection configurationRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server) -> kepconfig.admin.lls.lls_config:", "funcdef": "def"}, {"fullname": "kepconfig.admin.lls.update_lls_config", "modulename": "kepconfig.admin.lls", "qualname": "update_lls_config", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nUpdates the Local License Server connection properties for Kepware.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- config:
\nlls_configclass object with lls connection configurationReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tconfig: kepconfig.admin.lls.lls_config) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.lls.enable_lls", "modulename": "kepconfig.admin.lls", "qualname": "enable_lls", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nEnables the Local License Server connection for Kepware.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclassReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.lls.disable_lls", "modulename": "kepconfig.admin.lls", "qualname": "disable_lls", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDisables the Local License Server connection for Kepware.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclassReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.lls.force_license_check", "modulename": "kepconfig.admin.lls", "qualname": "force_license_check", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes a ForceLicenseCheck service call to the Kepware instance. This triggers the server to verify the \nlicense state of the license received from the Local License Server.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, job_ttl: int = None):", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server", "modulename": "kepconfig.admin.ua_server", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.admin.ua_server.add_endpoint", "modulename": "kepconfig.admin.ua_server", "qualname": "add_endpoint", "kind": "function", "doc": "
ua_serverexposes an API to allow modifications (add, delete, modify) to \nOPC UA Server endpoints within the Kepware Administration through the Kepware Configuration APIAdd an
\n\n\"endpoint\"or multiple\"endpoint\"objects to Kepware UA Server by passing a \nlist of endpoints to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the UA Endpoints to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n endpoints added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server.del_endpoint", "modulename": "kepconfig.admin.ua_server", "qualname": "del_endpoint", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete an
\n\n\"endpoint\"object in Kepware UA ServerParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- endpoint: name of endpoint to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, endpoint: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server.modify_endpoint", "modulename": "kepconfig.admin.ua_server", "qualname": "modify_endpoint", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"endpoint\"object and it's properties in Kepware UA Server. If a\"endpoint\"is not provided as an input,\nyou need to identify the endpoint in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the endpoint that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the UA endpoint properties to be modified.
\n- endpoint: (optional) name of endpoint to modify. Only needed if not existing in
\n\"DATA\"Returns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\tendpoint: str = None) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server.get_endpoint", "modulename": "kepconfig.admin.ua_server", "qualname": "get_endpoint", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"endpoint\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- endpoint: name of endpoint to retrieve
\nReturns
\n\n\n\n\nDict of properties for the UA endpoint requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, endpoint: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.admin.ua_server.get_all_endpoints", "modulename": "kepconfig.admin.ua_server", "qualname": "get_all_endpoints", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all
\n\n\"endpoint\"objects and their properties.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of UA endpoints. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize.
\nReturns
\n\n\n\n\nList of properties for all UA endpoints requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups", "modulename": "kepconfig.admin.user_groups", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.admin.user_groups.add_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "add_user_group", "kind": "function", "doc": "
user_groupsexposes an API to allow modifications (add, delete, modify) to \nuser groups within the Kepware Administration User Manager through the Kepware Configuration APIAdd a
\n\n\"user group\"or multiple\"user group\"objects to Kepware User Manager by passing a \nlist of user groups to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the user groups to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n endpoints added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.del_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "del_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"user group\"object in Kepware User ManagerParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user_group: name of user group to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.modify_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "modify_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"user group\"object and it's properties in Kepware User Manager. If a\"user group\"is not provided as an input,\nyou need to identify the user group in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the user group that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the user group properties to be modified.
\n- user_group: (optional) name of user group to modify. Only needed if not existing in
\n\"DATA\"Returns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tuser_group: str = None) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.get_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "get_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"user group\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user_group: name of user group to retrieve
\nReturns
\n\n\n\n\nDict of properties for the user group requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user_group: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.get_all_user_groups", "modulename": "kepconfig.admin.user_groups", "qualname": "get_all_user_groups", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all
\n\n\"user group\"objects and their properties.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of user groups. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize.
\nReturns
\n\n\n\n\nList of properties for all user groups
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.enable_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "enable_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nEnable the
\n\n\"user group\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user_group: name of user group
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.user_groups.disable_user_group", "modulename": "kepconfig.admin.user_groups", "qualname": "disable_user_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDisable the
\n\n\"user group\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user_group: name of user group
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users", "modulename": "kepconfig.admin.users", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.admin.users.add_user", "modulename": "kepconfig.admin.users", "qualname": "add_user", "kind": "function", "doc": "
usersexposes an API to allow modifications (add, delete, modify) to \nusers within the Kepware Administration User Management through the Kepware Configuration APIAdd a
\n\n\"user\"or multiple\"user\"objects to Kepware User Manager by passing a \nlist of users to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the users to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n endpoints added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.del_user", "modulename": "kepconfig.admin.users", "qualname": "del_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"user\"object in Kepware User ManagerParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user: name of user to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.modify_user", "modulename": "kepconfig.admin.users", "qualname": "modify_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"user object\"and it's properties in Kepware User Manager. If a\"user\"is not provided as an input,\nyou need to identify the user in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the user that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the user properties to be modified.
\n- user: (optional) name of user to modify. Only needed if not existing in
\n\"DATA\"Returns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tuser: str = None) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.get_user", "modulename": "kepconfig.admin.users", "qualname": "get_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"user\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user: name of user to retrieve
\nReturns
\n\n\n\n\nDict of properties for the user requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.get_all_users", "modulename": "kepconfig.admin.users", "qualname": "get_all_users", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all
\n\n\"user\"objects and their properties.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of users. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize.
\nReturns
\n\n\n\n\nList of properties for all users
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.enable_user", "modulename": "kepconfig.admin.users", "qualname": "enable_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nEnable the
\n\n\"user\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user: name of user
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.admin.users.disable_user", "modulename": "kepconfig.admin.users", "qualname": "disable_user", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDisable the
\n\n\"user\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- user: name of user
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, user: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connection", "modulename": "kepconfig.connection", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connection.server", "modulename": "kepconfig.connection", "qualname": "server", "kind": "class", "doc": "
connectionexposes anserverclass that manages the connection\ninformation and RESTful requests for the Kepware Configuration API Library.A class to represent a connection to an instance of Kepware. This object is used to \ncreate the Authentication and server parameters to taget a Kepware instance. An instance of this is \nused in all configuration calls done.
\n\nParameters
\n\n\n
\n\n- host: host name or IP address
\n- port: port of Configuration API
\n- username: username to conduct \"Basic Authentication\"
\n- password: password to conduct \"Basic Authentication\"
\n- https: Sets
\nSSL_onto use HTTPS connection (Default: False)- SSL_on: Identify to use HTTPS connection (Default: False)
\n- SSL_ignore_hostname: During certificate validation ignore the hostname check
\n- SSL_trust_all_certs: (insecure) - During certificate validation trust any certificate - if True, \nwill \"set SSL_ignore_hostname\" to true
\n- url: base URL for the server connection
\nMethods
\n\n\n\n
reinitialize(): reinitialize the Kepware server\n\n
get_transaction_log(): retrieve the Configuration API transaction logs\n\n
get_event_log(): retrieve the Kepware Event Log\n\n
get_project_properties(): retrieve the Kepware Project Properties\n\n
modify_project_properties()- modify the Kepware Project Properties\n"}, {"fullname": "kepconfig.connection.server.__init__", "modulename": "kepconfig.connection", "qualname": "server.__init__", "kind": "function", "doc": "\n", "signature": "(host: str, port: int, user: str, pw: str, https: bool = False)"}, {"fullname": "kepconfig.connection.server.get_status", "modulename": "kepconfig.connection", "qualname": "server.get_status", "kind": "function", "doc": "
service_status()- retrive service job statusExecutes a health status request to the Kepware instance to report service statuses.
\n\nReturns
\n\n\n\n\nList of data for the health status request
\nRaises
\n\n\n
\n", "signature": "(self) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.get_info", "modulename": "kepconfig.connection", "qualname": "server.get_info", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nRequests product information from the Kepware instance. Provides various information including\nproduct name and version information.
\n\nReturns
\n\n\n\n\ndict of data for the product information request
\nRaises
\n\n\n
\n", "signature": "(self) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.reinitialize", "modulename": "kepconfig.connection", "qualname": "server.reinitialize", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes a Reinitialize service call to the Kepware instance.
\n\nParameters
\n\n\n
\n\n- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(self, job_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.get_transaction_log", "modulename": "kepconfig.connection", "qualname": "server.get_transaction_log", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\nGet the Transaction Log from the Kepware instance.
\n\nParameters
\n\n\n
\n\n- limit: (optional) number of transaction log entries to request
\n- start: (optional) start time of query as
\ndatetime.datetimetype and should be UTC- end: (optional) end time of query as
\ndatetime.datetimetype and should be UTCRaises
\n\n\n
\n", "signature": "(\tself,\tlimit: int = None,\tstart: datetime.datetime = None,\tend: datetime.datetime = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.get_event_log", "modulename": "kepconfig.connection", "qualname": "server.get_event_log", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nGet the Event Log from the Kepware instance.
\n\nParameters
\n\n\n
\n\n- limit: (optional) number of event log entries to request
\n- start: (optional) start time of query as
\ndatetime.datetimetype and should be UTC- end: (optional) end time of query as
\ndatetime.datetimetype and should be UTC- options: (optional) Dict of parameters to filter, sort or pagenate the list of transactions. Options are
\nevent, \nsortOrder,sortProperty,pageNumber, andpageSizeRaises
\n\n\n
\n", "signature": "(\tself,\tlimit: int = None,\tstart: datetime.datetime = None,\tend: datetime.datetime = None,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.get_project_properties", "modulename": "kepconfig.connection", "qualname": "server.get_project_properties", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nGet the Project Properties of the Kepware instance.
\n\nReturns
\n\n\n\n\nDict of all the project properties
\nRaises
\n\n\n
\n", "signature": "(self) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.modify_project_properties", "modulename": "kepconfig.connection", "qualname": "server.modify_project_properties", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify the Project Properties of the Kepware instance.
\n\nParameters
\n\n\n
\n\n- DATA: Dict of the project properties to be modified
\n- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(self, DATA: dict, force: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.save_project", "modulename": "kepconfig.connection", "qualname": "server.save_project", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes a ProjectSave Service call to the Kepware instance. This saves \na copy of the current project file to disk. The filename
\n\nParameters
\n\n\n
\n\n- \n
filename: Relative file path and name of project file including the file extension to save.\nLocation of relative project file paths:
\n\nTKS or KEP (Windows): C:\\PROGRAMDATA\\PTC\\Thingworx Kepware Server\\V6 or \n C:\\PROGRAMDATA\\Kepware\\KEPServerEX\\V6\nTKE (Linux): /opt/tkedge/v1/user_data\n- \n
password: (optional) Specify a password with which to save an encrypted project file with.
\nThis password will be required to load this project file.- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(\tself,\tfilename: str,\tpassword: str = None,\tjob_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.load_project", "modulename": "kepconfig.connection", "qualname": "server.load_project", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\nExecutes a ProjectLoad Service call to the Kepware instance. This loads \na project file to disk.
\n\nINPUTS:
\n\nParameters
\n\n\n
\n\n- \n
filename: Fully qualified or relative path and name of project file including the file extension. Absolute\npaths required for TKS and KEP while file path is relative for TKE:
\n\nWindows - filename = C:\\filepath\\test.opf\nLinux - filename = filepath/test.lpf - Location is /opt/tkedge/v1/user_data/filepath/test.lpf\n- \n
password: (optional) Specify a password with which to load an encrypted project file.
- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(\tself,\tfilename: str,\tpassword: str = None,\tjob_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.connection.server.service_status", "modulename": "kepconfig.connection", "qualname": "server.service_status", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\nReturns the status of a service job. Used to verify if a service call\nhas completed or not.
\n\nParameters
\n\n\n
\n\n- resp:
\nKepServiceResponseinstance with job informationReturns
\n\n\n\n\n\n
KepServiceStatusinstance with job statusRaises
\n\n\n
\n", "signature": "(self, resp: kepconfig.structures.KepServiceResponse):", "funcdef": "def"}, {"fullname": "kepconfig.connectivity", "modulename": "kepconfig.connectivity", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n\n
connectivitymodule provides functionality to manage Kepware driver configuration \navailable through the Kepware Configuration API. This includes channels, devices, \ntags, tag groups and driver specific objects.Driver specific object support, if available, through their own modules. Currently\nthe GE Ethernet Global Data and Universal Device Drivers have driver specific API\nsupport in the SDK.
\n"}, {"fullname": "kepconfig.connectivity.channel", "modulename": "kepconfig.connectivity.channel", "kind": "module", "doc": "\n"}, {"fullname": "kepconfig.connectivity.channel.add_channel", "modulename": "kepconfig.connectivity.channel", "qualname": "add_channel", "kind": "function", "doc": "
channelexposes an API to allow modifications (add, delete, modify) to \nchannel objects within the Kepware Configuration APIAdd a
\n\n\"channel\"or multiple\"channel\"objects to Kepware. Can be used to pass children of a channel object \nsuch as devices and tags/tag groups. This allows you to create a channel, it's devices and tags \nall in one function, if desired.Additionally it can be used to pass a list of channels and it's children to be added all at once.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the channel and it's children\nexpected by Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n channels added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.del_channel", "modulename": "kepconfig.connectivity.channel", "qualname": "del_channel", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"channel\"object in Kepware. This will delete all children as wellParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel: name of channel
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, channel: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.modify_channel", "modulename": "kepconfig.connectivity.channel", "qualname": "modify_channel", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a channel object and it's properties in Kepware. If a
\n\n\"channel\"is not provided as an input,\nyou need to identify the channel in the 'common.ALLTYPES_NAME' property field in\"DATA\". It will \nassume that is the channel that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the
\nchannelproperties to be modified- channel: (optional) name of channel to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tchannel: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.get_channel", "modulename": "kepconfig.connectivity.channel", "qualname": "get_channel", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the channel object.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel: name of channel
\nReturns
\n\n\n\n\nDict of data for the channel requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, channel: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.get_all_channels", "modulename": "kepconfig.connectivity.channel", "qualname": "get_all_channels", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all channel objects and their properties.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of channels. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSizeReturns
\n\n\n\n\nList of data for all channels in Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.channel.get_channel_structure", "modulename": "kepconfig.connectivity.channel", "qualname": "get_channel_structure", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of
\n\n\"channel\"and includes all\"devices\"and the\"tag\"and\"tag group\"objects for a \nchannel in Kepware. Returned object is a dict of channel properties including a device list with \ntag lists and tag group lists.The returned object resembles the example below, nested based on how many \nlevels the tag_group namespace has tags or tag_groups:
\n\nExample return:
\n\n\n\n{\n channel_properties,\n 'devices: [\n {\n device1_properties,\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel: name of channel
\nReturns
\n\n\n\n\nDict of data for the channel structure requested for
\n\"channel\"Raises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, channel: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device", "modulename": "kepconfig.connectivity.device", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.device.add_device", "modulename": "kepconfig.connectivity.device", "qualname": "add_device", "kind": "function", "doc": "
deviceexposes an API to allow modifications (add, delete, modify) to \ndevice objects within the Kepware Configuration APIAdd a
\n\n\"device\"or multiple\"device\"objects to a channel in Kepware. Can be used to pass children of a device object \nsuch as tags and tag groups. This allows you to create a device and tags \nall in one function, if desired.Additionally it can be used to pass a list of devices and it's children to be added all at once.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel_name: channel to add the device object(s)
\n- DATA: Dict or List of Dicts of the device(s) and it's children\nexpected by Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n devices added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tchannel_name: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.del_device", "modulename": "kepconfig.connectivity.device", "qualname": "del_device", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"device\"object in Kepware. This will delete all children as well.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to delete. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"Returns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, device_path: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.modify_device", "modulename": "kepconfig.connectivity.device", "qualname": "modify_device", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a device object and it's properties in Kepware.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"- DATA: Dict of the
\ndeviceproperties to be modified- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tDATA: dict,\t*,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.get_device", "modulename": "kepconfig.connectivity.device", "qualname": "get_device", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the device object.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to retrieve properties. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"Returns
\n\n\n\n\nDict of data for the device requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, device_path: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.get_all_devices", "modulename": "kepconfig.connectivity.device", "qualname": "get_all_devices", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all device objects and their properties within a channel. Returned object is JSON list.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- channel: name of channel
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of devices. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSizeReturns
\n\n\n\n\nList of data for all devices within the channel
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tchannel_name: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.auto_tag_gen", "modulename": "kepconfig.connectivity.device", "qualname": "auto_tag_gen", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes Auto Tag Generation function on devices that support the feature in Kepware
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- \n
device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the \ndevice such as
\"channel1.device1\"- \n
job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
Returns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tjob_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.get_all_tags_tag_groups", "modulename": "kepconfig.connectivity.device", "qualname": "get_all_tags_tag_groups", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"tag\"and\"tag group\"objects for as specific\ndevice in Kepware. Returned object is a dict of tag list and tag group list.The returned object resembles the example below, nested based on how many \nlevels the tag_group namespace has tags or tag_groups:
\n\nExample return:
\n\n\n\n{\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"Returns
\n\n\n\n\nDict of data for the tag structure for device requested at
\n\"device_path\"locationRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, device_path: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.device.get_device_structure", "modulename": "kepconfig.connectivity.device", "qualname": "get_device_structure", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of
\n\n\"device\"and includes all\"tag\"and\"tag group\"objects for as specific\ndevice in Kepware. Returned object is a dict of device properties including a tag list and tag group list.The returned object resembles example below, nested based on how many \nlevels the tag_group namespace has tags or tag_groups:
\n\nExample return:
\n\n\n\n{\n device_properties,\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the \ndevice such as
\n\"channel1.device1\"Returns
\n\n\n\n\nDict of data for the device structure at
\n\"device_path\"locationRaises
\n\n\n
\n", "signature": "(server, device_path) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd", "modulename": "kepconfig.connectivity.egd", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.egd.exchange", "modulename": "kepconfig.connectivity.egd.exchange", "kind": "module", "doc": "
egdmodule provides support for GE EGD driver specific objects \nwithin the Kepware Configuration API\n"}, {"fullname": "kepconfig.connectivity.egd.exchange.add_exchange", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "add_exchange", "kind": "function", "doc": "
exchangeexposes an API to allow modifications (add, delete, modify) to \nexchange objects for EGD devices within the Kepware Configuration APIAdd a
\n\n\"exchange\"or multiple\"exchange\"objects to Kepware. Can be used to pass children of a exchange object \nsuch as ranges. This allows you to create a exchange and ranges for the exchange all in one function, if desired.Additionally it can be used to pass a list of exchanges and it's children to be added all at once.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- DATA: Dict or List of Dicts of the exchange(s) and it's children\nexpected by Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n exchanges added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.exchange.del_exchange", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "del_exchange", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete an
\n\n\"exchange\"object in Kepware. This will delete all children as wellParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.exchange.modify_exchange", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "modify_exchange", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"exchange\"object and it's properties in Kepware. If a\"exchange_name\"is not provided as an input,\nyou need to identify the exchange in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the exchange that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- DATA: Dict of the exchange properties to be modified.
\n- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: (optional) name of exchange to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\tDATA: dict,\t*,\texchange_name: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.exchange.get_exchange", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "get_exchange", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the exchange object or a list of all exchanges and their \nproperties for the type input. Returned object is JSON.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: (optional) name of exchange. If not defined, get all exchanges
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nDict of properties for the exchange requested or a List of exchanges and their properties
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str = None,\t*,\toptions: dict = None) -> Union[dict, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.exchange.get_all_exchanges", "modulename": "kepconfig.connectivity.egd.exchange", "qualname": "get_all_exchanges", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all
\n\n\"exchange\"objects (both CONSUMER and PRODUCER) and their properties. Returned object is JSON list.INPUTS:
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device with exchanges. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- options: (optional) Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nList - [list of consumer exchanges, list of producer exchanges] - list of lists for all \n exchanges for the device
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\t*,\toptions: dict = None) -> list[list, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.name", "modulename": "kepconfig.connectivity.egd.name", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.egd.name.add_name_resolution", "modulename": "kepconfig.connectivity.egd.name", "qualname": "add_name_resolution", "kind": "function", "doc": "
namesexposes an API to allow modifications (add, delete, modify) to \nname resolution objects for EGD devices within the Kepware Configuration APIAdd a
\n\n\"name resolution\"or multiple\"name resolution\"objects to Kepware. This allows you to \ncreate a name resolution or multiple name resolutions all in one function, if desired.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- DATA: Dict or List of Dicts of name resolutions\nexpected by Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n name resolutions added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.name.del_name_resolution", "modulename": "kepconfig.connectivity.egd.name", "qualname": "del_name_resolution", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"name resolution\"object in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- name: name of name resolution to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, device_path: str, name: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.name.modify_name_resolution", "modulename": "kepconfig.connectivity.egd.name", "qualname": "modify_name_resolution", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"name resolution\"object and it's properties in Kepware. If a\"name\"is not provided as an input,\nyou need to identify the name resolution in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the name resolution that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- DATA: Dict of name resolution properties to be modified
\n- name: (optional) name of name resolution to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tDATA: dict,\t*,\tname: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.name.get_name_resolution", "modulename": "kepconfig.connectivity.egd.name", "qualname": "get_name_resolution", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"name resolution\"object or a list of all name resolutions.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- DATA: Dict of name resolution properties to be modified
\n- name: (optional) name of name resolution to retrieve. If not defined, will get all name resolutions
\n- options: (optional) Dict of parameters to filter, sort or pagenate when getting a list of profiles. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSize. Only used when\"name\"is not defined.Returns
\n\n\n\n\nDict of the name resolution properties or List of Dicts for all name resolutions and their properties
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tname: str = None,\t*,\toptions: dict = None) -> Union[dict, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.range", "modulename": "kepconfig.connectivity.egd.range", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.egd.range.add_range", "modulename": "kepconfig.connectivity.egd.range", "qualname": "add_range", "kind": "function", "doc": "
rangesexposes an API to allow modifications (add, delete, modify) to \nrange objects in exchanges for EGD devices within the Kepware Configuration APIAdd a
\n\n\"range\"or multiple\"range\"objects to Kepware. This allows you to \ncreate a range or multiple ranges all in one function, if desired.When passing multiple ranges, they will be populated in the same order\nin the list sent. Ensure you provide the list in the order desired.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange that range is located
\n- DATA: Dict or List of Dicts of the range(s) to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n ranges added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.range.del_range", "modulename": "kepconfig.connectivity.egd.range", "qualname": "del_range", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"range\"object in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange that range is located
\n- range_name: name of range to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str,\trange_name: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.range.modify_range", "modulename": "kepconfig.connectivity.egd.range", "qualname": "modify_range", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"range\"object and it's properties in Kepware. If a\"range_name\"is not provided as an input,\nyou need to identify the range in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the range that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange that range is located
\n- DATA: Dict of the range properties to be modified.
\n- range_name: (optional) name of range to to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str,\tDATA: dict,\t*,\trange_name: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.egd.range.get_range", "modulename": "kepconfig.connectivity.egd.range", "qualname": "get_range", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"range\"object or a list of all ranges.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path to EGD device. Standard Kepware address decimal \nnotation string such as
\n\"channel1.device1\"- ex_type: type of exchange, either
\nCONSUMERorPRODUCER- exchange_name: name of exchange that range is located
\n- DATA: Dict of the range properties to be modified.
\n- range_name: (optional) name of range to retrieve. If not defined, get all ranges
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of exchanges. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when range_name is not defined.
\nReturns
\n\n\n\n\nDict of properties for the range requested or a List of ranges and their properties
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tdevice_path: str,\tex_type: str,\texchange_name: str,\trange_name: str = None,\t*,\toptions: dict = None) -> Union[dict, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag", "modulename": "kepconfig.connectivity.tag", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.tag.add_tag", "modulename": "kepconfig.connectivity.tag", "qualname": "add_tag", "kind": "function", "doc": "
tagexposes an API to allow modifications (add, delete, modify) to \ntag and tag group objects within the Kepware Configuration APIAdd
\n\n\"tag\"or multiple\"tag\"objects to a specific path in Kepware. \nCan be used to pass a list of tags to be added at one path location.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- device_path: path identifying where to add tag(s). Standard Kepware address decimal \nnotation string that tags exists such as \"channel1.device1.tag_group1\" or \"channel1.device1\"
\n- DATA: Dict or List of Dicts of the tag(s) to add
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n tags added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\ttag_path: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.add_tag_group", "modulename": "kepconfig.connectivity.tag", "qualname": "add_tag_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nAdd
\n\n\"tag_group\"or multiple\"tag_group\"objects to a specific path in Kepware. \nCan be used to pass a list of tag_groups and children (tags or tag groups) to be added at one \npath location.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying where to add tag group(s). Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\" or \"channel1.device1\"
\n- DATA: Dict or List of Dicts of the tag group(s) to add and it's children (tags or tag groups)
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n tag groups added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\ttag_group_path: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.add_all_tags", "modulename": "kepconfig.connectivity.tag", "qualname": "add_all_tags", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nAdd
\n\n\"tag\"and\"tag group\"objects to a device in Kepware. To be used to \npass a list of tags, tag groups and/or children of tag groups (tags and tag \ngroups) to be added at once. See example below for required structure with \n\"tags\" and \"tag_groups\" as keys:Example DATA:
\n\n\n\n{\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- ch_dev_path: device path identifying where to add tags and tag groups. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1\"
\n- DATA: Dict of the tags and tag groups to add and it's children (tags or tag groups).
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nList [tag failure list, tag group failure list] - If a \"HTTP 207 - Multi-Status\" is received from \n Kepware for either tags or tag groups, a list of dict error responses for all tags and/or tag groups added that failed.
\nReturns
\n\n\n\n\nFalse - If tags or tag groups are not found in DATA
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tch_dev_path: str,\tDATA: dict) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.modify_tag", "modulename": "kepconfig.connectivity.tag", "qualname": "modify_tag", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"tag\"object and it's properties in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- full_tag_path: path identifying location and tag to modify. Standard Kepware address decimal \nnotation string including the tag such as \"channel1.device1.tag_group1.tag1\"
\n- DATA: Dict of the
\ntagproperties to be modified- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tfull_tag_path: str,\tDATA: dict,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.modify_tag_group", "modulename": "kepconfig.connectivity.tag", "qualname": "modify_tag_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"tag group\"object and it's properties in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying location and tag group to modify. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\"
\n- DATA: Dict of the
\ntag groupproperties to be modified- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\ttag_group_path: str,\tDATA: dict,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.del_tag", "modulename": "kepconfig.connectivity.tag", "qualname": "del_tag", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete
\n\n\"tag\"object at a specific path in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- full_tag_path: path identifying location and tag to delete. Standard Kepware address decimal \nnotation string including the tag such as \"channel1.device1.tag_group1.tag1\"
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, full_tag_path: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.del_tag_group", "modulename": "kepconfig.connectivity.tag", "qualname": "del_tag_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete
\n\n\"tag group\"object at a specific path in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying location and tag group to delete. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\"
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, tag_group_path: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_tag", "modulename": "kepconfig.connectivity.tag", "qualname": "get_tag", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"tag\"object at a specific path in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- full_tag_path: path identifying location and tag to delete. Standard Kepware address decimal \nnotation string including the tag such as \"channel1.device1.tag_group1.tag1\"
\nReturns
\n\n\n\n\nDict of data for the tag requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, full_tag_path: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_all_tags", "modulename": "kepconfig.connectivity.tag", "qualname": "get_all_tags", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"tag\"object at a specific path in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- full_tag_path: path identifying location to retreive tag list. Standard Kepware address decimal \nnotation string including the tag such as \"channel1.device1.tag_group1.tag1\"
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of tags. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSizeReturns
\n\n\n\n\nList of data for all tags
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tfull_tag_path: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_tag_group", "modulename": "kepconfig.connectivity.tag", "qualname": "get_tag_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the \"tag group\" object at a specific \npath in Kepware. Returned object is JSON.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying location and tag group to retrieve properties. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\"
\nReturns
\n\n\n\n\nDict of data for the tag group requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, tag_group_path: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_all_tag_groups", "modulename": "kepconfig.connectivity.tag", "qualname": "get_all_tag_groups", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"tag group\"objects at a specific \npath in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- tag_group_path: path identifying location to retrieve tag group list and properties. Standard Kepware address decimal \nnotation string that tag groups exists such as \"channel1.device1.tag_group1\"
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of devices. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSizeReturns
\n\n\n\n\nList of data for all tag groups
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\ttag_group_path: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.tag.get_full_tag_structure", "modulename": "kepconfig.connectivity.tag", "qualname": "get_full_tag_structure", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"tag\"and\"tag group\"objects at a specific \npath in Kepware. Returned object is a dict of tag list and tag group list.Example:
\n\n\n\n{\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[tag_group1_dict, tag_group2_dict,...]\n}\nIf
\n\nrecursiveis TRUE, then the call will iterate through all tag groups and get the tags and \ntag groups of all tag group children.This would be the equivilant of asking for all tags and tag groups\nthat exist below the\"path\"location. The returned object would look like below, nested based on how many \nlevels the tag_group namespace has tags or tag_groups:Example with Recursive True:
\n\n\n\n{\n 'tags': [tag1_dict, tag2_dict,...],\n 'tag_groups':[\n {\n tag_group1_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n }, \n {\n tag_group2_properties,\n 'tags': [tag1_dict, tag2_dict,...]\n 'tag_groups':[sub_group1, subgroup2,...]\n },...]\n}\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- path: path identifying location to retreive the tag structure. Standard Kepware address decimal \nnotation string such as \"channel1.device1.tag_group1\" and must container at least the channel and device.
\n- recursive: (optional) If True, returns structures within the tag groups found and all of their \nchildren. (default= False)
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of tags and tag groups. \nOptions are 'filter', 'sortOrder', and 'sortProperty' only.
\nReturns
\n\n\n\n\nDict of data for the tag structure requested at \"path\" location
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tpath: str,\t*,\trecursive: bool = False,\toptions: dict = None) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd", "modulename": "kepconfig.connectivity.udd", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.connectivity.udd.profile", "modulename": "kepconfig.connectivity.udd.profile", "kind": "module", "doc": "
uddmodule provides support for Universal Device driver specific objects \nwithin the Kepware Configuration API\n"}, {"fullname": "kepconfig.connectivity.udd.profile.add_profile", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "add_profile", "kind": "function", "doc": "
profileexposes an API to allow modifications (add, delete, modify) to \nprofile objects for the UDD Profile Library plug-in within the Kepware Configuration APIAdd a
\n\n\"profile\"or a list of\"profile\"objects to the UDD Profile Library plug-in for Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the profiles to add to the Profile Library \nthrough Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n profiles added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd.profile.del_profile", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "del_profile", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"profile\"object in UDD Profile Library plug-in for Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- profile_name: name of profile
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, profile_name: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd.profile.modify_profile", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "modify_profile", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"profile\"object and it's properties in Kepware. If a\"profile_name\"is not provided as an input,\nyou need to identify the profile in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the profile that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the profile properties to be modified.
\n- profile_name: (optional) name of profile to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\tprofile_name: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd.profile.get_profile", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "get_profile", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the profile object or a list of all profiles and their \nproperties. Will return a list if
\n\n\"profile_name\"is not provided.INPUTS:
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- profile_name: (optional) name of profile. If not defined, will get all profiles
\n- options: (optional) Dict of parameters to filter, sort or pagenate when getting a list of profiles. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSize. Only used when profile_name is not defined.Returns
\n\n\n\n\nDict of the profile properties or List of Dicts for all profiles and their properties in the Profile Library
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tprofile_name: str = None,\t*,\toptions: dict = None) -> Union[dict, list]:", "funcdef": "def"}, {"fullname": "kepconfig.connectivity.udd.profile.get_all_profiles", "modulename": "kepconfig.connectivity.udd.profile", "qualname": "get_all_profiles", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns list of all profile objects and their properties. Returned object is JSON list.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate when getting a list of profiles. Options are
\nfilter, \nsortOrder,sortProperty,pageNumber, andpageSize. Only used when profile_name is not defined.Returns
\n\n\n\n\nList of data for all profiles and their properties in the Profile Library
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None):", "funcdef": "def"}, {"fullname": "kepconfig.datalogger", "modulename": "kepconfig.datalogger", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.datalogger.log_group", "modulename": "kepconfig.datalogger.log_group", "kind": "module", "doc": "
dataloggermodule provides support for Kepware's Datalogger plug-in specific objects \nwithin the Kepware Configuration API\n"}, {"fullname": "kepconfig.datalogger.log_group.add_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "add_log_group", "kind": "function", "doc": "
log_groupexposes an API to allow modifications (add, delete, modify) to \nlog group objects in DataLogger within the Kepware Configuration APIAdd a
\n\n\"log group\"or multiple\"log groups\"objects to Kepware's DataLogger. It can be used \nto pass a list of log groups to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or a list of the log groups to add through Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n log groups added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.del_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "del_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"log group\"object in Kepware's Datalogger.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, log_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.modify_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "modify_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"log group\"object and it's properties in Kepware's Datalogger. If a\"log group\"is not provided as an input,\nyou need to identify the log group in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the log group that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the log group properties to be modified.
\n- log_group: (optional) name of log group to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tlog_group: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.get_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "get_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"log group\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to retrieve
\nReturns
\n\n\n\n\nDict of properties for the log group requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, log_group: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.get_all_log_groups", "modulename": "kepconfig.datalogger.log_group", "qualname": "get_all_log_groups", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all log group objects for Kepware's Datalogger. Returned object is JSON list.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- options: (optional) Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all log groups requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, *, options: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.enable_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "enable_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nEnable the
\n\n\"log group\".Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to enable
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, log_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.disable_log_group", "modulename": "kepconfig.datalogger.log_group", "qualname": "disable_log_group", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDisable the log group. Returned object is JSON.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to enable
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, log_group: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_group.reset_column_mapping_service", "modulename": "kepconfig.datalogger.log_group", "qualname": "reset_column_mapping_service", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nExecutes a ResetColumnMapping serivce call to the log group
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group to enable
\n- job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
\nReturns
\n\n\n\n\n\n
KepServiceResponseinstance with job informationRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tjob_ttl: int = None) -> kepconfig.structures.KepServiceResponse:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items", "modulename": "kepconfig.datalogger.log_items", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.datalogger.log_items.add_log_item", "modulename": "kepconfig.datalogger.log_items", "qualname": "add_log_item", "kind": "function", "doc": "
log_itemsexposes an API to allow modifications (add, delete, modify) to \nlog item (tag) objects in a Datalogger log group within the Kepware Configuration APIAdd a
\n\n\"log item\"or multiple\"log item\"objects to a log group in Kepware's Datalogger. It can \nbe used to pass a list of log items to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that the log items will be added
\n- DATA: Dict or a list of the log items to add through Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n log items added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items.del_log_item", "modulename": "kepconfig.datalogger.log_items", "qualname": "del_log_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"log item\"object of a log group in Kepware's Datalogger.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that log item exists
\n- log_item: name of log item to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tlog_item: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items.modify_log_item", "modulename": "kepconfig.datalogger.log_items", "qualname": "modify_log_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"log_item\"object and it's properties in Kepware. If a\"log_item\"is not provided as an input,\nyou need to identify the log_item in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the log_item that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that log item exists
\n- DATA: Dict of the log item properties to be modified.
\n- log_item: (optional) name of log item to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: dict,\t*,\tlog_item: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items.get_log_item", "modulename": "kepconfig.datalogger.log_items", "qualname": "get_log_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"log item\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that log item exists
\n- log_item: name of log item to retrieve
\nReturns
\n\n\n\n\nDict of properties for the log group requested
\nRaises
\n\n\n
\n", "signature": "(server, log_group, log_item) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.log_items.get_all_log_items", "modulename": "kepconfig.datalogger.log_items", "qualname": "get_all_log_items", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"log item\"objects for a log group.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group that log item exists
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of log groups. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all log items in the log group requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.mapping", "modulename": "kepconfig.datalogger.mapping", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.datalogger.mapping.modify_mapping", "modulename": "kepconfig.datalogger.mapping", "qualname": "modify_mapping", "kind": "function", "doc": "
mappingexposes an API to allow modifications (add, delete, modify) to \ncolumn mapping objects in a Datalogger log group within the Kepware Configuration APIModify a column
\n\n\"mapping\"object and it's properties in Kepware. If a\"mapping\"is not provided as an input,\nyou need to identify the column mapping in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the column mapping that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the mapping
\n- DATA: Dict of the mapping properties to be modified.
\n- mapping: (optional) column mapping to modify in the log group. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: dict,\t*,\tmapping: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.mapping.get_mapping", "modulename": "kepconfig.datalogger.mapping", "qualname": "get_mapping", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"mapping\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the mapping
\n- mapping: name of column mapping to retrieve properties
\nReturns
\n\n\n\n\nDict of properties for the mapping object requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tmapping: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.mapping.get_all_mappings", "modulename": "kepconfig.datalogger.mapping", "qualname": "get_all_mappings", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all column
\n\n\"mapping\"objects for a log group.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the mapping
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of mapping items. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all mapping items in the log group requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers", "modulename": "kepconfig.datalogger.triggers", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.datalogger.triggers.add_trigger", "modulename": "kepconfig.datalogger.triggers", "qualname": "add_trigger", "kind": "function", "doc": "
triggersexposes an API to allow modifications (add, delete, modify) to \ntrigger objects in a Datalogger log group within the Kepware Configuration APIAdd a
\n\n\"trigger\"or multiple\"trigger\"objects to a log group in Kepware's Datalogger. It can \nbe used to pass a list of triggers to be added all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\n- DATA: Dict or a list of the trigger items to add through Kepware Configuration API
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n triggers added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: Union[dict, list]) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers.del_trigger", "modulename": "kepconfig.datalogger.triggers", "qualname": "del_trigger", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"trigger\"object of a log group in Kepware's Datalogger.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\n- trigger: name of trigger to delete
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\ttrigger: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers.modify_trigger", "modulename": "kepconfig.datalogger.triggers", "qualname": "modify_trigger", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"trigger\"object and it's properties in Kepware. If a\"trigger\"is not provided as an input,\nyou need to identify the trigger in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the trigger that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\n- DATA: Dict of the trigger properties to be modified.
\n- trigger: (optional) name of trigger to modify in the log group. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\tDATA: dict,\t*,\ttrigger: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers.get_trigger", "modulename": "kepconfig.datalogger.triggers", "qualname": "get_trigger", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"trigger\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\n- trigger: name of trigger to retrieve
\nReturns
\n\n\n\n\nDict of properties for the trigger requested
\nRaises
\n\n\n
\n", "signature": "(server, log_group, trigger) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.datalogger.triggers.get_all_triggers", "modulename": "kepconfig.datalogger.triggers", "qualname": "get_all_triggers", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"trigger\"objects for a log group.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- log_group: name of log group for the trigger items
\nReturns
\n\n\n\n\nDict of properties for the trigger requested
\nRaises
\n\n\n
\n\n- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n- options: (optional) Dict of parameters to filter, sort or pagenate the list of triggers. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all triggers in the log group requested
\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tlog_group: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.error", "modulename": "kepconfig.error", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.error.KepError", "modulename": "kepconfig.error", "qualname": "KepError", "kind": "class", "doc": "
errorException classes raised by Kepconfig.\nIncludes KepError, KepURLError and KepHTTPErrorGeneral Exception class for Kepconfig.
\n\nParameters
\n\n\n
\n", "bases": "builtins.Exception"}, {"fullname": "kepconfig.error.KepError.__init__", "modulename": "kepconfig.error", "qualname": "KepError.__init__", "kind": "function", "doc": "\n", "signature": "(msg)"}, {"fullname": "kepconfig.error.KepURLError", "modulename": "kepconfig.error", "qualname": "KepURLError", "kind": "class", "doc": "- msg: General error message returned in string format.
\nException class raised by Kepconfig that derives responses from the urllib URLError exceptions.
\n\nParameters
\n\n\n
\n", "bases": "KepError"}, {"fullname": "kepconfig.error.KepURLError.__init__", "modulename": "kepconfig.error", "qualname": "KepURLError.__init__", "kind": "function", "doc": "\n", "signature": "(url=None, *args, **kwargs)"}, {"fullname": "kepconfig.error.KepHTTPError", "modulename": "kepconfig.error", "qualname": "KepHTTPError", "kind": "class", "doc": "- url: full url path of the request that flagged a URLError exception
\n- msg: reason parameter in URLError exception
\nException class raised by Kepconfig that derives responses from the urllib HTTPError \nexceptions. This exception class is also a valid HTTP response instance. It behaves \nthis way because HTTP protocol errors are valid responses, with a status \ncode, headers, and a body. In some contexts, an application may want to \nhandle an exception like a regular response.
\n\nParameters
\n\n\n
\n", "bases": "KepError"}, {"fullname": "kepconfig.error.KepHTTPError.__init__", "modulename": "kepconfig.error", "qualname": "KepHTTPError.__init__", "kind": "function", "doc": "\n", "signature": "(url=None, code=None, hdrs=None, payload=None, *args, **kwargs)"}, {"fullname": "kepconfig.iot_gateway", "modulename": "kepconfig.iot_gateway", "kind": "module", "doc": "- url: url parameter in HTTPError exception
\n- code: HTTP response code parameter in HTTPError exception
\n- hdrs: hdrs parameter in HTTPError exception
\n- payload: string of HTTP response payload that flagged HTTPError exception
\n- msg: msg parameter in HTTPError exception
\n\n"}, {"fullname": "kepconfig.iot_gateway.agent", "modulename": "kepconfig.iot_gateway.agent", "kind": "module", "doc": "
iot_gatewaymodule provides support for Kepware's IoT Gateway plug-in \nspecific objects within the Kepware Configuration API\n"}, {"fullname": "kepconfig.iot_gateway.agent.add_iot_agent", "modulename": "kepconfig.iot_gateway.agent", "qualname": "add_iot_agent", "kind": "function", "doc": "
agentexposes an API to allow modifications (add, delete, modify) to \nIot Gateway agent objects within the Kepware Configuration APIAdd a
\n\n\"agent\"or multiple\"agent\"objects of a specific type to Kepware's IoT Gateway. Can be used to pass children of an\nagent object such as iot items. This allows you to create an agent and iot items if desired. Multiple Agents need to be of the \nsame type.Additionally it can be used to pass a list of agents and it's children to be added all at once.
\n\nParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the agent and it's children\nexpected by Kepware Configuration API
\n- agent_type: (optional) agent type to add to IoT Gateway. Only needed if not existing in
\n\"DATA\". Valid values are \nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n iot agents added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list],\tagent_type: str = None) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.agent.del_iot_agent", "modulename": "kepconfig.iot_gateway.agent", "qualname": "del_iot_agent", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete a
\n\n\"agent\"object in Kepware. This will delete all children as wellParameters
\n\n\n
\n\n- server: instance of the
\nserverclass- agent: name of IoT Agent to delete
\n- agent_type: (optional) agent type to delete in IoT Gateway. Valid values are \n
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, agent: str, agent_type: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.agent.modify_iot_agent", "modulename": "kepconfig.iot_gateway.agent", "qualname": "modify_iot_agent", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify a
\n\n\"agent\"object and it's properties in Kepware. If a\"agent\"is not provided as an input,\nyou need to identify the agent in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the agent that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the iot agent properties to be modified.
\n- agent: (optional) name of IoT agent to modify. Only needed if not existing in
\n\"DATA\"- agent_type: (optional) agent type to modify. Only needed if not existing in
\n\"DATA\". Valid values are \nMQTT Client,REST ClientorREST Server- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\t*,\tagent: str = None,\tagent_type: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.agent.get_iot_agent", "modulename": "kepconfig.iot_gateway.agent", "qualname": "get_iot_agent", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"agent\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the iot agent properties to be modified.
\n- agent: name of IoT agent to retrieve
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nDict of properties for the iot agent requested
\nRaises
\n\n\n
\n", "signature": "(server: kepconfig.connection.server, agent: str, agent_type: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.agent.get_all_iot_agents", "modulename": "kepconfig.iot_gateway.agent", "qualname": "get_all_iot_agents", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"agent\"objects for a specific agent type. Returned object is JSON list.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST Server- options: (optional) Dict of parameters to filter, sort or pagenate the list of IoT agents. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all IoT agents requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tagent_type: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items", "modulename": "kepconfig.iot_gateway.iot_items", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.iot_gateway.iot_items.add_iot_item", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "add_iot_item", "kind": "function", "doc": "
iot_itemsexposes an API to allow modifications (add, delete, modify) to \niot_items objects within the Kepware Configuration APIAdd a
\n\n\"iot item\"or multiple\"iot item\"objects to Kepware's IoT Gateway agent. Additionally \nit can be used to pass a list of iot items to be added to an agent all at once.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict or List of Dicts of the iot item or list of items\nexpected by Kepware Configuration API
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nTrue - If a \"HTTP 201 - Created\" is received from Kepware server
\nReturns
\n\n\n\n\nIf a \"HTTP 207 - Multi-Status\" is received from Kepware with a list of dict error responses for all \n iot items added that failed.
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: Union[dict, list],\tagent: str,\tagent_type: str) -> Union[bool, list]:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items.del_iot_item", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "del_iot_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nDelete an
\n\n\"iot item\"object in Kepware.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- iot_item: IoT item to delete
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tiot_item: str,\tagent: str,\tagent_type: str) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items.modify_iot_item", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "modify_iot_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nModify an
\n\n\"iot item\"object and it's properties in Kepware. If a\"iot item\"is not provided as an input,\nyou need to identify the iot item in the 'common.ALLTYPES_NAME' property field in the\"DATA\". It will \nassume that is the iot item that is to be modified.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- DATA: Dict of the iot item properties to be modified.
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST Server- iot_item: (optional) name of IoT item to modify. Only needed if not existing in
\n\"DATA\"- force: (optional) if True, will force the configuration update to the Kepware server
\nReturns
\n\n\n\n\nTrue - If a \"HTTP 200 - OK\" is received from Kepware server
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tDATA: dict,\tagent: str,\tagent_type: str,\t*,\tiot_item: str = None,\tforce: bool = False) -> bool:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items.get_iot_item", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "get_iot_item", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of the
\n\n\"iot item\"object.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- iot_item: name of IoT item to retrieve properties
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST ServerReturns
\n\n\n\n\nDict of properties for the iot item requested
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tiot_item: str,\tagent: str,\tagent_type: str) -> dict:", "funcdef": "def"}, {"fullname": "kepconfig.iot_gateway.iot_items.get_all_iot_items", "modulename": "kepconfig.iot_gateway.iot_items", "qualname": "get_all_iot_items", "kind": "function", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\nReturns the properties of all
\n\n\"iot item\"objects for an agent.Parameters
\n\n\n
\n\n- server: instance of the
\nserverclass- iot_item: name of IoT item to retrieve properties
\n- agent: name of IoT Agent
\n- agent_type: agent type. Valid values are
\nMQTT Client,REST ClientorREST Server- options: (optional) Dict of parameters to filter, sort or pagenate the list of IoT items. Options are 'filter', \n'sortOrder', 'sortProperty', 'pageNumber', and 'pageSize'. Only used when exchange_name is not defined.
\nReturns
\n\n\n\n\nlist of properties for all IoT items
\nRaises
\n\n\n
\n", "signature": "(\tserver: kepconfig.connection.server,\tagent: str,\tagent_type: str,\t*,\toptions: dict = None) -> list:", "funcdef": "def"}, {"fullname": "kepconfig.structures", "modulename": "kepconfig.structures", "kind": "module", "doc": "- KepHTTPError: If urllib provides an HTTPError
\n- KepURLError: If urllib provides an URLError
\n\n"}, {"fullname": "kepconfig.structures.KepServiceResponse", "modulename": "kepconfig.structures", "qualname": "KepServiceResponse", "kind": "class", "doc": "
structuresprovides general data structures to help manage \nvarious objects for Kepware's configurationA class to represent a return object when calling a \"service\" API of Kepware. This is\nused to return the responses when a \"service\" is executed appropriately
\n\nParameters
\n\n\n
\n"}, {"fullname": "kepconfig.structures.KepServiceResponse.__init__", "modulename": "kepconfig.structures", "qualname": "KepServiceResponse.__init__", "kind": "function", "doc": "\n", "signature": "(code: str = '', message: str = '', href: str = '')"}, {"fullname": "kepconfig.structures.KepServiceStatus", "modulename": "kepconfig.structures", "qualname": "KepServiceStatus", "kind": "class", "doc": "- \n
code: HTTP code returned
- \n
message: return from the \"service\" call
- \n
href: URL reference to the JOB that is created by the service API
A class to represent a status object when checking on a \"service\" API job state in Kepware. This is\nused to return the status of a \"service\" job
\n\nParameters
\n\n\n
\n"}, {"fullname": "kepconfig.structures.KepServiceStatus.__init__", "modulename": "kepconfig.structures", "qualname": "KepServiceStatus.__init__", "kind": "function", "doc": "\n", "signature": "(complete: str = '', status: str = '', message: str = '')"}, {"fullname": "kepconfig.utils", "modulename": "kepconfig.utils", "kind": "module", "doc": "- \n
complete: Boolean of service job completion status
- \n
status: Status code of job
- \n
message: Error message if service job fails
\n"}, {"fullname": "kepconfig.utils.path_split", "modulename": "kepconfig.utils", "qualname": "path_split", "kind": "function", "doc": "
utilsprovides general utilities to help manage \nvarious objects for Kepware's configurationUsed to split the standard Kepware address decimal notation into a dict that contains the \nchannel, device and tag_path keys.
\n\nParameters
\n\n\n
\n\n- path: standard Kepware address in decimal notation (\"ch1.dev1.tg1.tg2.tg3\")
\nReturns
\n\n\n\n\ndict that contains the \"channel\", \"device\" and \"tag_path\"
\nEx: path = \"ch1.dev1.tg1.tg2.tg3\"
\n\nreturn = {'channel': 'ch1', 'device': 'dev1', 'tag_path': ['tg1','tg2','tg3']}
\n\nEx: path = \"ch1.dev1\"
\n\nreturn = {'channel': 'ch1', 'device': 'dev1'}
\n", "signature": "(path: str):", "funcdef": "def"}]; // mirrored in build-search-index.js (part 1) // Also split on html tags. this is a cheap heuristic, but good enough. diff --git a/kepconfig/__init__.py b/kepconfig/__init__.py index ab0b9d5..d1028b3 100644 --- a/kepconfig/__init__.py +++ b/kepconfig/__init__.py @@ -18,7 +18,6 @@ .. include:: ../README.md """ -__version__ = "1.2.0" +__version__ = "1.2.1" from . import connection, error -from .utils import path_split diff --git a/kepconfig/admin/ua_server.py b/kepconfig/admin/ua_server.py index 72ab7bd..408e283 100644 --- a/kepconfig/admin/ua_server.py +++ b/kepconfig/admin/ua_server.py @@ -10,6 +10,7 @@ from typing import Union from ..error import KepHTTPError, KepError from ..connection import server +from ..utils import _url_parse_object UA_ROOT = '/admin/ua_endpoints' @@ -24,7 +25,7 @@ def _create_url(endpoint = None): if endpoint == None: return UA_ROOT else: - return '{}/{}'.format(UA_ROOT,endpoint) + return '{}/{}'.format(UA_ROOT, _url_parse_object(endpoint)) def add_endpoint(server: server, DATA: Union[dict, list]) -> Union[bool, list]: '''Add an `"endpoint"` or multiple `"endpoint"` objects to Kepware UA Server by passing a diff --git a/kepconfig/admin/user_groups.py b/kepconfig/admin/user_groups.py index 2fa1f89..1a8884a 100644 --- a/kepconfig/admin/user_groups.py +++ b/kepconfig/admin/user_groups.py @@ -10,6 +10,7 @@ from typing import Union from ..error import KepHTTPError, KepError from ..connection import server +from ..utils import _url_parse_object USERGROUPS_ROOT = '/admin/server_usergroups' @@ -25,7 +26,7 @@ def _create_url(user_group = None): if user_group == None: return USERGROUPS_ROOT else: - return '{}/{}'.format(USERGROUPS_ROOT,user_group) + return '{}/{}'.format(USERGROUPS_ROOT, _url_parse_object(user_group)) def add_user_group(server: server, DATA: Union[dict, list]) -> Union[bool, list]: '''Add a `"user group"` or multiple `"user group"` objects to Kepware User Manager by passing a diff --git a/kepconfig/admin/users.py b/kepconfig/admin/users.py index c549c01..347495f 100644 --- a/kepconfig/admin/users.py +++ b/kepconfig/admin/users.py @@ -10,6 +10,7 @@ from typing import Union from ..error import KepError, KepHTTPError from ..connection import server +from ..utils import _url_parse_object USERS_ROOT = '/admin/server_users' @@ -25,7 +26,7 @@ def _create_url(user = None): if user == None: return USERS_ROOT else: - return '{}/{}'.format(USERS_ROOT,user) + return '{}/{}'.format(USERS_ROOT, _url_parse_object(user)) def add_user(server: server, DATA: Union[dict, list]) -> Union[bool, list]: '''Add a `"user"` or multiple `"user"` objects to Kepware User Manager by passing a diff --git a/kepconfig/connection.py b/kepconfig/connection.py index 551e7ad..58ccccb 100644 --- a/kepconfig/connection.py +++ b/kepconfig/connection.py @@ -431,7 +431,9 @@ def __connect(self,request_obj): # Fucntion used to ensure special characters are handled in the URL # Ex: Space will be turned to %20 def __url_validate(self, url): - parsed_url = parse.urlparse(url) + # Configuration API does not use fragments in URL so ignore to allow # as a character + # Objects in Kepware can include # as part of the object names + parsed_url = parse.urlparse(url, allow_fragments= False) # Added % for scenarios where special characters have already been escaped with % updated_path = parse.quote(parsed_url.path, safe = '/%') diff --git a/kepconfig/connectivity/channel.py b/kepconfig/connectivity/channel.py index c4347dc..ed8339a 100644 --- a/kepconfig/connectivity/channel.py +++ b/kepconfig/connectivity/channel.py @@ -13,6 +13,7 @@ import inspect from ..connection import server from ..error import KepHTTPError, KepError +from ..utils import _url_parse_object from typing import Union from . import device @@ -28,7 +29,7 @@ def _create_url(channel = None): if channel == None: return CHANNEL_ROOT else: - return '{}/{}'.format(CHANNEL_ROOT,channel) + return '{}/{}'.format(CHANNEL_ROOT,_url_parse_object(channel)) def add_channel(server: server, DATA: Union[dict, list]) -> Union[bool, list]: '''Add a `"channel"` or multiple `"channel"` objects to Kepware. Can be used to pass children of a channel object @@ -84,7 +85,7 @@ def modify_channel(server: server, DATA: dict, *, channel: str = None, force: bo :param server: instance of the `server` class :param DATA: Dict of the `channel` properties to be modified - :param channel: *(optional)* - name of channel to modify. Only needed if not existing in `"DATA"` + :param channel: *(optional)* name of channel to modify. Only needed if not existing in `"DATA"` :param force: *(optional)* if True, will force the configuration update to the Kepware server :return: True - If a "HTTP 200 - OK" is received from Kepware server diff --git a/kepconfig/connectivity/device.py b/kepconfig/connectivity/device.py index 981bda3..fe2569c 100644 --- a/kepconfig/connectivity/device.py +++ b/kepconfig/connectivity/device.py @@ -11,8 +11,8 @@ from ..connection import KepServiceResponse, server from ..error import KepHTTPError, KepError +from ..utils import _url_parse_object, path_split from typing import Union -import kepconfig from . import channel, tag import inspect @@ -28,7 +28,7 @@ def _create_url(device = None): if device == None: return DEVICE_ROOT else: - return '{}/{}'.format(DEVICE_ROOT,device) + return '{}/{}'.format(DEVICE_ROOT,_url_parse_object(device)) def add_device(server: server, channel_name: str, DATA: Union[dict, list]) -> Union[bool, list]: '''Add a `"device"` or multiple `"device"` objects to a channel in Kepware. Can be used to pass children of a device object @@ -74,7 +74,7 @@ def del_device(server: server, device_path: str) -> bool: :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(device_path) + path_obj = path_split(device_path) try: r = server._config_del(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device'])) if r.code == 200: return True @@ -100,7 +100,7 @@ def modify_device(server: server, device_path: str, DATA: dict, *, force: bool = device_data = server._force_update_check(force, DATA) - path_obj = kepconfig.path_split(device_path) + path_obj = path_split(device_path) try: r = server._config_update(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device']), device_data) if r.code == 200: return True @@ -122,7 +122,7 @@ def get_device(server: server, device_path: str) -> dict: :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(device_path) + path_obj = path_split(device_path) try: r = server._config_get(server.url + channel._create_url(path_obj['channel']) + _create_url(path_obj['device'])) return r.payload @@ -164,7 +164,7 @@ def auto_tag_gen(server: server, device_path: str, job_ttl: int = None) -> KepSe :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(device_path) + path_obj = path_split(device_path) try: url = server.url +channel._create_url(path_obj['channel']) + _create_url(path_obj['device']) + ATG_URL job = server._kep_service_execute(url, None, job_ttl) diff --git a/kepconfig/connectivity/egd/exchange.py b/kepconfig/connectivity/egd/exchange.py index 8d4a678..bf6ecc8 100644 --- a/kepconfig/connectivity/egd/exchange.py +++ b/kepconfig/connectivity/egd/exchange.py @@ -9,9 +9,9 @@ exchange objects for EGD devices within the Kepware Configuration API """ -from ... import path_split from ...connection import server from ...error import KepHTTPError, KepError +from ...utils import _url_parse_object, path_split from typing import Union from .. import egd as EGD, channel, device @@ -34,9 +34,9 @@ def _create_url(device_path, ex_type, exchange_name = None): return device_root + PRODUCER_ROOT else: if ex_type.upper() == EGD.CONSUMER_EXCHANGE: - return '{}{}/{}'.format(device_root,CONSUMER_ROOT,exchange_name) + return '{}{}/{}'.format(device_root,CONSUMER_ROOT,_url_parse_object(exchange_name)) else: - return '{}{}/{}'.format(device_root,PRODUCER_ROOT,exchange_name) + return '{}{}/{}'.format(device_root,PRODUCER_ROOT,_url_parse_object(exchange_name)) def add_exchange(server: server, device_path: str, ex_type: str, DATA: Union[dict, list]) -> Union[bool, list]: '''Add a `"exchange"` or multiple `"exchange"` objects to Kepware. Can be used to pass children of a exchange object diff --git a/kepconfig/connectivity/egd/name.py b/kepconfig/connectivity/egd/name.py index 1dc2af2..36f9e4a 100644 --- a/kepconfig/connectivity/egd/name.py +++ b/kepconfig/connectivity/egd/name.py @@ -9,7 +9,7 @@ name resolution objects for EGD devices within the Kepware Configuration API """ -from ... import path_split +from ...utils import _url_parse_object, path_split from ...connection import server from ...error import KepHTTPError, KepError from typing import Union @@ -29,7 +29,7 @@ def _create_url(device_path, name = None): if name == None: return '{}/{}'.format(device_root, NAMES_ROOT) else: - return '{}/{}/{}'.format(device_root, NAMES_ROOT, name) + return '{}/{}/{}'.format(device_root, NAMES_ROOT, _url_parse_object(name)) def add_name_resolution(server: server, device_path: str, DATA: Union[dict, list]) -> Union[bool, list]: '''Add a `"name resolution"` or multiple `"name resolution"` objects to Kepware. This allows you to diff --git a/kepconfig/connectivity/egd/range.py b/kepconfig/connectivity/egd/range.py index 1ff75d4..d3ca530 100644 --- a/kepconfig/connectivity/egd/range.py +++ b/kepconfig/connectivity/egd/range.py @@ -13,6 +13,7 @@ from .. import egd as EGD from ...connection import server from ...error import KepError, KepHTTPError +from ...utils import _url_parse_object RANGES_ROOT = '/ranges' @@ -27,7 +28,7 @@ def _create_url(device_path, ex_type, exchange_name, range = None): if range == None: return '{}{}'.format(exchange_root, RANGES_ROOT) else: - return '{}{}/{}'.format(exchange_root, RANGES_ROOT, range) + return '{}{}/{}'.format(exchange_root, RANGES_ROOT, _url_parse_object(range)) def add_range(server: server, device_path: str, ex_type: str, exchange_name: str, DATA: Union[dict, list]) -> Union[bool, list]: '''Add a `"range"` or multiple `"range"` objects to Kepware. This allows you to diff --git a/kepconfig/connectivity/tag.py b/kepconfig/connectivity/tag.py index 8d3b86f..2e85789 100644 --- a/kepconfig/connectivity/tag.py +++ b/kepconfig/connectivity/tag.py @@ -11,8 +11,8 @@ from ..connection import server from ..error import KepError, KepHTTPError +from ..utils import _url_parse_object, path_split from typing import Union -import kepconfig from . import channel, device import inspect @@ -28,7 +28,7 @@ def _create_tags_url(tag = None): if tag == None: return TAGS_ROOT else: - return '{}/{}'.format(TAGS_ROOT,tag) + return '{}/{}'.format(TAGS_ROOT, _url_parse_object(tag)) def _create_tag_groups_url(tag_group = None): '''Creates url object for the "tag_group" branch of Kepware's project tree. Used @@ -39,7 +39,7 @@ def _create_tag_groups_url(tag_group = None): if tag_group == None: return TAG_GRP_ROOT else: - return '{}/{}'.format(TAG_GRP_ROOT,tag_group) + return '{}/{}'.format(TAG_GRP_ROOT,_url_parse_object(tag_group)) def add_tag(server: server, tag_path: str, DATA: Union[dict, list]) -> Union[bool, list]: '''Add `"tag"` or multiple `"tag"` objects to a specific path in Kepware. @@ -58,7 +58,7 @@ def add_tag(server: server, tag_path: str, DATA: Union[dict, list]) -> Union[boo :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(tag_path) + path_obj = path_split(tag_path) try: url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) if 'tag_path' in path_obj: @@ -99,7 +99,7 @@ def add_tag_group(server: server, tag_group_path: str, DATA: Union[dict, list]) :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(tag_group_path) + path_obj = path_split(tag_group_path) try: url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) if 'tag_path' in path_obj: @@ -201,7 +201,7 @@ def modify_tag(server: server, full_tag_path: str, DATA: dict, force: bool = Fal tag_data = server._force_update_check(force, DATA) - path_obj = kepconfig.path_split(full_tag_path) + path_obj = path_split(full_tag_path) try: url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) for x in range(0, len(path_obj['tag_path'])-1): @@ -234,7 +234,7 @@ def modify_tag_group(server: server, tag_group_path: str, DATA: dict, force: boo tag_group_data = server._force_update_check(force, DATA) - path_obj = kepconfig.path_split(tag_group_path) + path_obj = path_split(tag_group_path) try: url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) for tg in path_obj['tag_path']: @@ -262,7 +262,7 @@ def del_tag(server: server, full_tag_path: str) -> bool: :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(full_tag_path) + path_obj = path_split(full_tag_path) try: url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) for x in range(0, len(path_obj['tag_path'])-1): @@ -291,7 +291,7 @@ def del_tag_group(server: server, tag_group_path: str) -> bool: :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(tag_group_path) + path_obj = path_split(tag_group_path) try: url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) for tg in path_obj['tag_path']: @@ -319,7 +319,7 @@ def get_tag(server: server, full_tag_path: str) -> dict: :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(full_tag_path) + path_obj = path_split(full_tag_path) try: url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) for x in range(0, len(path_obj['tag_path'])-1): @@ -349,7 +349,7 @@ def get_all_tags(server: server, full_tag_path: str, *, options: dict = None) -> :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(full_tag_path) + path_obj = path_split(full_tag_path) try: url = f"{server.url}{channel._create_url(path_obj['channel'])}{device._create_url(path_obj['device'])}" if 'tag_path' in path_obj: @@ -378,7 +378,7 @@ def get_tag_group(server: server, tag_group_path: str) -> dict: :raises KepHTTPError: If urllib provides an HTTPError :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(tag_group_path) + path_obj = path_split(tag_group_path) try: url = server.url+channel._create_url(path_obj['channel'])+device._create_url(path_obj['device']) for tg in path_obj['tag_path']: @@ -407,7 +407,7 @@ def get_all_tag_groups(server:server, tag_group_path: str, *, options: dict = No :raises KepHTTPError: If urllib provides an HTTPError :raises KepURLError: If urllib provides an URLError ''' - path_obj = kepconfig.path_split(tag_group_path) + path_obj = path_split(tag_group_path) try: url = f"{server.url}{channel._create_url(path_obj['channel'])}{device._create_url(path_obj['device'])}" if 'tag_path' in path_obj: diff --git a/kepconfig/datalogger/log_group.py b/kepconfig/datalogger/log_group.py index aefd4de..31796ef 100644 --- a/kepconfig/datalogger/log_group.py +++ b/kepconfig/datalogger/log_group.py @@ -10,6 +10,7 @@ from typing import Union from ..connection import KepServiceResponse, server from ..error import KepError, KepHTTPError +from ..utils import _url_parse_object ENABLE_PROPERTY = 'datalogger.LOG_GROUP_ENABLED' LOG_GROUP_ROOT = '/project/_datalogger/log_groups' @@ -24,7 +25,7 @@ def _create_url(log_group = None): if log_group == None: return '{}'.format(LOG_GROUP_ROOT) else: - return '{}/{}'.format(LOG_GROUP_ROOT, log_group) + return '{}/{}'.format(LOG_GROUP_ROOT, _url_parse_object(log_group)) def add_log_group(server: server, DATA: Union[dict, list]) -> Union[bool, list]: diff --git a/kepconfig/datalogger/log_items.py b/kepconfig/datalogger/log_items.py index 69346f9..385e0d9 100644 --- a/kepconfig/datalogger/log_items.py +++ b/kepconfig/datalogger/log_items.py @@ -11,6 +11,7 @@ from . import log_group as Log_Group from ..error import KepError, KepHTTPError from ..connection import server +from ..utils import _url_parse_object LOG_ITEMS_ROOT = '/log_items' @@ -24,7 +25,7 @@ def _create_url(log_item = None): if log_item == None: return '{}'.format(LOG_ITEMS_ROOT) else: - return '{}/{}'.format(LOG_ITEMS_ROOT, log_item) + return '{}/{}'.format(LOG_ITEMS_ROOT, _url_parse_object(log_item)) def add_log_item(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: diff --git a/kepconfig/datalogger/mapping.py b/kepconfig/datalogger/mapping.py index b34d5a0..8975de5 100644 --- a/kepconfig/datalogger/mapping.py +++ b/kepconfig/datalogger/mapping.py @@ -11,6 +11,7 @@ from . import log_group as Log_Group from ..error import KepError, KepHTTPError from ..connection import server +from ..utils import _url_parse_object MAPPING_ROOT = '/column_mappings' @@ -24,7 +25,7 @@ def _create_url(mapping = None): if mapping == None: return '{}'.format(MAPPING_ROOT) else: - return '{}/{}'.format(MAPPING_ROOT, mapping) + return '{}/{}'.format(MAPPING_ROOT, _url_parse_object(mapping)) def modify_mapping(server: server, log_group: str, DATA: dict, *, mapping: str = None, force: bool = False) -> bool: '''Modify a column `"mapping"` object and it's properties in Kepware. If a `"mapping"` is not provided as an input, diff --git a/kepconfig/datalogger/triggers.py b/kepconfig/datalogger/triggers.py index 556ad5d..52389a2 100644 --- a/kepconfig/datalogger/triggers.py +++ b/kepconfig/datalogger/triggers.py @@ -12,6 +12,7 @@ from . import log_group as Log_Group from ..error import KepError, KepHTTPError from ..connection import server +from ..utils import _url_parse_object TRIGGERS_ROOT = '/triggers' @@ -25,7 +26,7 @@ def _create_url(trigger = None): if trigger == None: return '{}'.format(TRIGGERS_ROOT) else: - return '{}/{}'.format(TRIGGERS_ROOT, trigger) + return '{}/{}'.format(TRIGGERS_ROOT, _url_parse_object(trigger)) def add_trigger(server: server, log_group: str, DATA: Union[dict, list]) -> Union[bool, list]: diff --git a/kepconfig/iot_gateway/agent.py b/kepconfig/iot_gateway/agent.py index 84b7f3a..5adf908 100644 --- a/kepconfig/iot_gateway/agent.py +++ b/kepconfig/iot_gateway/agent.py @@ -15,6 +15,7 @@ from .. import iot_gateway as IOT from ..error import KepError, KepHTTPError import inspect +from ..utils import _url_parse_object IOT_ROOT_URL = '/project/_iot_gateway' MQTT_CLIENT_URL = '/mqtt_clients' @@ -42,13 +43,13 @@ def _create_url(agent_type, agent = None): pass else: if agent_type == IOT.MQTT_CLIENT_AGENT: - return '{}{}/{}'.format(IOT_ROOT_URL, MQTT_CLIENT_URL, agent) + return '{}{}/{}'.format(IOT_ROOT_URL, MQTT_CLIENT_URL, _url_parse_object(agent)) elif agent_type == IOT.REST_CLIENT_AGENT: - return '{}{}/{}'.format(IOT_ROOT_URL, REST_CLIENT_URL, agent) + return '{}{}/{}'.format(IOT_ROOT_URL, REST_CLIENT_URL, _url_parse_object(agent)) elif agent_type == IOT.REST_SERVER_AGENT: - return '{}{}/{}'.format(IOT_ROOT_URL, REST_SERVER_URL,agent) + return '{}{}/{}'.format(IOT_ROOT_URL, REST_SERVER_URL,_url_parse_object(agent)) elif agent_type == IOT.THINGWORX_AGENT: - return '{}{}/{}'.format(IOT_ROOT_URL, THINGWORX_URL, agent) + return '{}{}/{}'.format(IOT_ROOT_URL, THINGWORX_URL, _url_parse_object(agent)) else: pass @@ -76,22 +77,22 @@ def add_iot_agent(server: server, DATA: Union[dict, list], agent_type: str = Non if agent_type == None: try: - r = server._config_update(server.url + _create_url(DATA['iot_gateway.AGENTTYPES_TYPE']), DATA) - if r.code == 201: return True - else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + # If it's a list, use the first agents type + if isinstance(DATA, list): agent_type = DATA[0]['iot_gateway.AGENTTYPES_TYPE'] + else: agent_type = DATA['iot_gateway.AGENTTYPES_TYPE'] except KeyError as err: err_msg = 'Error: No agent identified in DATA | Key Error: {}'.format(err) raise KepError(err_msg) - else: - r = server._config_add(server.url + _create_url(agent_type), DATA) - if r.code == 201: return True - elif r.code == 207: - errors = [] - for item in r.payload: - if item['code'] != 201: - errors.append(item) - return errors - else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) + + r = server._config_add(server.url + _create_url(agent_type), DATA) + if r.code == 201: return True + elif r.code == 207: + errors = [] + for item in r.payload: + if item['code'] != 201: + errors.append(item) + return errors + else: raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload) def del_iot_agent(server: server, agent: str, agent_type: str) -> bool: '''Delete a `"agent"` object in Kepware. This will delete all children as well diff --git a/kepconfig/iot_gateway/iot_items.py b/kepconfig/iot_gateway/iot_items.py index 41edb42..6118416 100644 --- a/kepconfig/iot_gateway/iot_items.py +++ b/kepconfig/iot_gateway/iot_items.py @@ -14,6 +14,7 @@ from ..connection import server from .. import iot_gateway as IOT from ..error import KepError, KepHTTPError +from ..utils import _url_parse_object IOT_ITEMS_ROOT = '/iot_items' @@ -27,7 +28,7 @@ def _create_url(tag = None): return IOT_ITEMS_ROOT else: normalized_tag = utils._address_dedecimal(tag) - return '{}/{}'.format(IOT_ITEMS_ROOT,normalized_tag) + return '{}/{}'.format(IOT_ITEMS_ROOT, _url_parse_object(normalized_tag)) def add_iot_item(server: server, DATA: Union[dict, list], agent: str, agent_type: str) -> Union[bool, list]: diff --git a/kepconfig/utils.py b/kepconfig/utils.py index 8609054..e157ebc 100644 --- a/kepconfig/utils.py +++ b/kepconfig/utils.py @@ -8,6 +8,8 @@ various objects for Kepware's configuration """ +from urllib import parse + def path_split(path: str): '''Used to split the standard Kepware address decimal notation into a dict that contains the *channel*, *device* and *tag_path* keys. @@ -36,7 +38,17 @@ def path_split(path: str): return path_obj def _address_dedecimal(tag_address): + '''Used to handle URL references where decimal notation isn't supported in object names, i.e. IoT Gateway items. + + Replaces `.` with `_` and removes leading `_` for system tag references''' if tag_address[0] == '_': tag_address = tag_address[1::] updated = tag_address.replace('.','_') return updated + +def _url_parse_object(object): + '''Common url parse to handle reserved characters. Used to convert object + names when building URLs. + + Reserved character list that Kepware allows in object names: :/?#[]@!$&'()*+,;=''' + return parse.quote(object, safe='') diff --git a/tests/connectivity_test.py b/tests/connectivity_test.py index 726ee26..c4001f3 100644 --- a/tests/connectivity_test.py +++ b/tests/connectivity_test.py @@ -17,14 +17,17 @@ # Channel and Device name to be used -ch_name = 'Channel1' -dev_name = 'Device1' +ch_name = 'Chan:/?#[]@!$&\'()*+,;=nel1' #Added special characters to ensure proper handling. +dev_name = 'Dev:/?#[]@!$&\'()*+,;=ice1' mqtt_agent_name = 'MQTT' rest_agent_name = 'REST Client' rserver_agent_name = 'REST Server' twx_agent_name = 'Thingworx' iot_item_name ="System__Date" +tagnm = "Te:/?#[]@!$&\'()*+,;=mp1" +taggrpnm = 'AL:/?#[]@!$&\'()*+,;=ARM' + def HTTPErrorHandler(err): if err.__class__ is error.KepHTTPError: print(err.code) @@ -109,16 +112,17 @@ def test_device_add(server): def test_all_tag_tg_add(server): # Add a collection of Tags and Tag Group objects + all_tags_data = { "tags": [ { - "common.ALLTYPES_NAME": "Temp1", + "common.ALLTYPES_NAME": tagnm, "servermain.TAG_ADDRESS": "R0" } ], "tag_groups": [ { - "common.ALLTYPES_NAME": "ALARM", + "common.ALLTYPES_NAME": taggrpnm, "tags": [ { "common.ALLTYPES_NAME": "ALARM_C_READY", @@ -267,7 +271,7 @@ def test_tag_add(server): "servermain.TAG_ADDRESS": "R1" } ] - tag_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM.ALARM2') + tag_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}.ALARM2') assert connectivity.tag.add_tag(server, tag_path, tag_info) @@ -292,7 +296,7 @@ def test_tag_group_add(server): "common.ALLTYPES_NAME": "NewGroup" } ] - tag_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM') + tag_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}') assert connectivity.tag.add_tag_group(server, tag_path, tag_group_info) # Add tag group to at device level (test for no "tag path") @@ -349,11 +353,11 @@ def test_device_tag_all_get(server): def test_tag_get(server): # Get Tag - tag_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM.ALARM2.temp') + tag_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}.ALARM2.temp') assert type(connectivity.tag.get_tag(server, tag_path)) == dict # Get All Tags - tag_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM.ALARM2') + tag_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}.ALARM2') assert type(connectivity.tag.get_all_tags(server, tag_path)) == list # @@ -369,12 +373,12 @@ def test_tag_get(server): def test_tag_group_get(server): # Get Tag Group - tag_group_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM.ALARM2') + tag_group_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}.ALARM2') assert type(connectivity.tag.get_tag_group(server, tag_group_path)) == dict # Get All Tag Groups - tag_group_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM') + tag_group_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}') assert type(connectivity.tag.get_all_tag_groups(server,tag_group_path)) == list # @@ -382,7 +386,7 @@ def test_tag_group_get(server): # # Get Tag Group - tag_group_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM') + tag_group_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}') assert type(connectivity.tag.get_tag_group(server, tag_group_path)) == dict # Get All Tag Groups @@ -395,7 +399,7 @@ def test_tag_struct_get(server): # proj_id = props['PROJECT_ID'] tag_path = '{}.{}'.format(ch_name, dev_name) assert type(connectivity.tag.get_full_tag_structure(server, tag_path, recursive=True)) == dict - tag_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM.ALARM2') + tag_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}.ALARM2') assert type(connectivity.tag.get_full_tag_structure(server, tag_path)) == dict @@ -429,12 +433,12 @@ def test_auto_tag_gen(server): def test_tag_del(server): # Delete Tag - tag_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM.ALARM2.temp') + tag_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}.ALARM2.temp') assert connectivity.tag.del_tag(server, tag_path) def test_tag_group_del(server): # Delete Tag Group - tag_group_path = '{}.{}.{}'.format(ch_name, dev_name, 'ALARM.ALARM2') + tag_group_path = '{}.{}.{}'.format(ch_name, dev_name, f'{taggrpnm}.ALARM2') assert connectivity.tag.del_tag_group(server, tag_group_path) def test_device_del(server): diff --git a/tests/iot_gateway_test.py b/tests/iot_gateway_test.py index b02fc44..0f967c0 100644 --- a/tests/iot_gateway_test.py +++ b/tests/iot_gateway_test.py @@ -116,6 +116,26 @@ def test_agent_add(server): with pytest.raises(KepError): assert kepconfig.iot_gateway.agent.add_iot_agent(server, agent) + # Add Agent with agent type in DATA + agent['common.ALLTYPES_NAME'] = agent_name + "2" + agent['iot_gateway.AGENTTYPES_TYPE'] = agent_type + + assert kepconfig.iot_gateway.agent.add_iot_agent(server, agent) + + # Add list of agents with agent type in DATA + agent = [ + { + "common.ALLTYPES_NAME": agent_name + "3", + 'iot_gateway.AGENTTYPES_TYPE': agent_type + }, + { + "common.ALLTYPES_NAME": agent_name + "4", + 'iot_gateway.AGENTTYPES_TYPE': agent_type + } + ] + + assert kepconfig.iot_gateway.agent.add_iot_agent(server, agent) + # Add Agent with bad name (HTTP 207 return with list) agent = [ { @@ -128,6 +148,21 @@ def test_agent_add(server): assert type(kepconfig.iot_gateway.agent.add_iot_agent(server, agent, agent_type)) == list + # Add Agent list without agent type in Data (error) + agent = [ + { + "common.ALLTYPES_NAME": agent_name + "1" + }, + { + "common.ALLTYPES_NAME": "_" + agent_name + } + ] + with pytest.raises(KepError): + assert kepconfig.iot_gateway.agent.add_iot_agent(server, agent, agent_type) + + + + def test_agent_modify(server): for agent_name, agent_type in agent_list: # Modify Agent