1515from ..error import KepError , KepHTTPError
1616from ..ua_gateway .common import _INTER_TYPE , _change_cert_trust , _create_url_cert , _create_url_client , _delete_cert_truststore
1717
18- def get_certificate (server : server , certificate : str ) -> dict :
19- '''Returns the properties of the UAG client connection certificate object in the UAG client connection
20- certificate store. These are UA server instance certificates that are used by UAG client connections for
21- trust purposes in the UA security model.
22-
23- :param server: instance of the `server` class
24- :param certificate: name of certificate
25-
26- :return: Dict of data for the certificate requested
27-
28- :raises KepHTTPError: If urllib provides an HTTPError
29- :raises KepURLError: If urllib provides an URLError
30- '''
31- r = server ._config_get (server .url + _create_url_cert (_INTER_TYPE .CLIENT , certificate ))
32- return r .payload
33-
34- def get_all_certificates (server : server , * , options : dict = None ) -> list :
35- '''Returns list of all UAG client connection certificate objects and their properties. These are UA server instance
36- certificates that are used by UAG client connections for trust purposes in the UA security model.
37-
38- :param server: instance of the `server` class
39- :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of certificates. Options are `filter`,
40- `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
41-
42- :return: List of data for all certificates in Kepware server UAG client connection certificate store
43-
44- :raises KepHTTPError: If urllib provides an HTTPError
45- :raises KepURLError: If urllib provides an URLError
46- '''
47- r = server ._config_get (server .url + _create_url_cert (_INTER_TYPE .CLIENT ), params = options )
48- return r .payload
49-
50- def trust_certificate (server : server , certificate : str ) -> bool :
51- '''Trusts the certificate in the UAG client connection certifcate store. This is updating the trust state of UA server instance
52- certificates that are used by UAG client connections for trust purposes in the UA security model.
53-
54- :param server: instance of the `server` class
55- :param certificate: name of certificate
56-
57- :return: True - If a "HTTP 200 - OK" is received from Kepware server
58-
59- :raises KepHTTPError: If urllib provides an HTTPError
60- :raises KepURLError: If urllib provides an URLError
61- '''
62- return _change_cert_trust (server , _INTER_TYPE .CLIENT , certificate , True )
63-
64- def reject_certificate (server : server , certificate : str ) -> bool :
65- '''Rejects the certificate in the UAG client connection certifcate store. This is updating the trust state of UA server instance
66- certificates that are used by UAG client connections for trust purposes in the UA security model.
67-
68- :param server: instance of the `server` class
69- :param certificate: name of certificate
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- return _change_cert_trust (server , _INTER_TYPE .CLIENT , certificate , False )
78-
79- def delete_certificate (server : server , certificate : str ) -> bool :
80- '''Deletes the certificate in the UAG client endpoint certificate store.
81-
82- :param server: instance of the `server` class
83- :param certificate: name of certificate
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- return _delete_cert_truststore (server , _INTER_TYPE .CLIENT , certificate )
91-
9218def get_ua_client_connection (server : server , ua_client_connection : str ) -> dict :
9319 '''Returns the properties of the UAG client connection object.
9420
@@ -192,4 +118,78 @@ def del_ua_client_connection(server: server, ua_client_connection: str) -> bool:
192118 r = server ._config_del (server .url + _create_url_client (ua_client_connection ))
193119 if r .code == 200 : return True
194120 else :
195- raise KepHTTPError (r .url , r .code , r .msg , r .hdrs , r .payload )
121+ raise KepHTTPError (r .url , r .code , r .msg , r .hdrs , r .payload )
122+
123+ def get_certificate (server : server , certificate : str ) -> dict :
124+ '''Returns the properties of the UAG client connection certificate object in the UAG client connection
125+ certificate store. These are UA server instance certificates that are used by UAG client connections for
126+ trust purposes in the UA security model.
127+
128+ :param server: instance of the `server` class
129+ :param certificate: name of certificate
130+
131+ :return: Dict of data for the certificate requested
132+
133+ :raises KepHTTPError: If urllib provides an HTTPError
134+ :raises KepURLError: If urllib provides an URLError
135+ '''
136+ r = server ._config_get (server .url + _create_url_cert (_INTER_TYPE .CLIENT , certificate ))
137+ return r .payload
138+
139+ def get_all_certificates (server : server , * , options : dict = None ) -> list :
140+ '''Returns list of all UAG client connection certificate objects and their properties. These are UA server instance
141+ certificates that are used by UAG client connections for trust purposes in the UA security model.
142+
143+ :param server: instance of the `server` class
144+ :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of certificates. Options are `filter`,
145+ `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
146+
147+ :return: List of data for all certificates in Kepware server UAG client connection certificate store
148+
149+ :raises KepHTTPError: If urllib provides an HTTPError
150+ :raises KepURLError: If urllib provides an URLError
151+ '''
152+ r = server ._config_get (server .url + _create_url_cert (_INTER_TYPE .CLIENT ), params = options )
153+ return r .payload
154+
155+ def trust_certificate (server : server , certificate : str ) -> bool :
156+ '''Trusts the certificate in the UAG client connection certifcate store. This is updating the trust state of UA server instance
157+ certificates that are used by UAG client connections for trust purposes in the UA security model.
158+
159+ :param server: instance of the `server` class
160+ :param certificate: name of certificate
161+
162+ :return: True - If a "HTTP 200 - OK" is received from Kepware server
163+
164+ :raises KepHTTPError: If urllib provides an HTTPError
165+ :raises KepURLError: If urllib provides an URLError
166+ '''
167+ return _change_cert_trust (server , _INTER_TYPE .CLIENT , certificate , True )
168+
169+ def reject_certificate (server : server , certificate : str ) -> bool :
170+ '''Rejects the certificate in the UAG client connection certifcate store. This is updating the trust state of UA server instance
171+ certificates that are used by UAG client connections for trust purposes in the UA security model.
172+
173+ :param server: instance of the `server` class
174+ :param certificate: name of certificate
175+
176+ :return: True - If a "HTTP 200 - OK" is received from Kepware server
177+
178+ :raises KepHTTPError: If urllib provides an HTTPError
179+ :raises KepURLError: If urllib provides an URLError
180+ '''
181+
182+ return _change_cert_trust (server , _INTER_TYPE .CLIENT , certificate , False )
183+
184+ def delete_certificate (server : server , certificate : str ) -> bool :
185+ '''Deletes the certificate in the UAG client endpoint certificate store.
186+
187+ :param server: instance of the `server` class
188+ :param certificate: name of certificate
189+
190+ :return: True - If a "HTTP 200 - OK" is received from Kepware server
191+
192+ :raises KepHTTPError: If urllib provides an HTTPError
193+ :raises KepURLError: If urllib provides an URLError
194+ '''
195+ return _delete_cert_truststore (server , _INTER_TYPE .CLIENT , certificate )
0 commit comments