1111"""
1212
1313from typing import Union
14+
15+ from kepconfig .structures import KepServiceResponse
1416from ..connection import server
1517from ..error import KepError , KepHTTPError
16- from ..ua_gateway .common import _INTER_TYPE , _change_cert_trust , _create_url_cert , _create_url_server , _delete_cert_truststore , SERVER_ROOT
18+ from ..ua_gateway .common import _INTER_TYPE , _change_cert_trust , _create_url_cert , _create_url_server , _delete_cert_truststore , SERVER_ROOT , _create_url_inst_cert
19+
20+ SERVER_INSTANCE_CERTIFICATE = 'Server Instance Certificate'
1721
1822def get_uag_server_interface_properties (server : server ) -> dict :
1923 ''' Get the UAG Server Interface Properties of the Kepware instance. These properties expose User Identify
@@ -224,4 +228,37 @@ def delete_certificate(server: server, certificate: str) -> bool:
224228 :raises KepHTTPError: If urllib provides an HTTPError
225229 :raises KepURLError: If urllib provides an URLError
226230 '''
227- return _delete_cert_truststore (server , _INTER_TYPE .SERVER , certificate )
231+ return _delete_cert_truststore (server , _INTER_TYPE .SERVER , certificate )
232+
233+ def get_instance_certificate (server : server ) -> dict :
234+ '''Returns the properties of the UAG server instance certificate object in the UAG certificate store.
235+ These are UAG instance certificates that are used by UAG for trust purposes in the UA security model.
236+
237+ :param server: instance of the `server` class
238+
239+ :return: Dict of properties for the certificate requested
240+
241+ :raises KepHTTPError: If urllib provides an HTTPError
242+ :raises KepURLError: If urllib provides an URLError
243+ '''
244+ r = server ._config_get (server .url + _create_url_inst_cert (_INTER_TYPE .SERVER , SERVER_INSTANCE_CERTIFICATE ))
245+ return r .payload
246+
247+ def reissue_self_signed_instance_certificate (server : server , job_ttl : int = None ) -> KepServiceResponse :
248+ '''Deletes and reissues a self-signed UAG server instance certificate object in the UAG certificate store.
249+ This is the UAG instance certificate that are used by UAG for trust purposes in the UA security model.
250+
251+ :param server: instance of the `server` class
252+ :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
253+
254+ :return: `KepServiceResponse` instance with job information
255+
256+ :raises KepHTTPError: If urllib provides an HTTPError
257+ :raises KepURLError: If urllib provides an URLError
258+ '''
259+ url = server .url + _create_url_inst_cert (_INTER_TYPE .SERVER , SERVER_INSTANCE_CERTIFICATE ) + '/services/ReIssueInstanceCertificate'
260+ try :
261+ job = server ._kep_service_execute (url , TTL = job_ttl )
262+ return job
263+ except Exception as err :
264+ raise err
0 commit comments