Skip to content

Commit ba93672

Browse files
committed
Refactored API - Instance Verbiage
1 parent 3a5c160 commit ba93672

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

kepconfig/ua_gateway/certificates.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99
"""
1010

1111
from ..connection import server
12-
from ..ua_gateway.common import _INTER_TYPE, _create_url_cert
12+
from ..error import KepHTTPError
13+
from ..ua_gateway.common import _INTER_TYPE, _create_url_cert, INSTANCE_CERTIFICATE
1314

14-
def get_certificate(server: server, certificate: str) -> dict:
15+
def get_instance_certificate(server: server) -> dict:
1516
'''Returns the properties of the UAG instance certificate object in the UAG certificate store.
1617
These are UAG instance certificates that are used by UAG for trust purposes in the UA security model.
1718
1819
:param server: instance of the `server` class
19-
:param certificate: name of certificate
2020
2121
:return: Dict of data for the certificate requested
2222
2323
:raises KepHTTPError: If urllib provides an HTTPError
2424
:raises KepURLError: If urllib provides an URLError
2525
'''
26-
r = server._config_get(server.url + _create_url_cert(_INTER_TYPE.CERTS, certificate))
26+
r = server._config_get(server.url + _create_url_cert(_INTER_TYPE.CERTS, INSTANCE_CERTIFICATE))
2727
return r.payload
2828

2929
def get_all_certificates(server: server, *, options: dict = None) -> list:
@@ -40,4 +40,20 @@ def get_all_certificates(server: server, *, options: dict = None) -> list:
4040
:raises KepURLError: If urllib provides an URLError
4141
'''
4242
r = server._config_get(server.url + _create_url_cert(_INTER_TYPE.CERTS), params= options)
43-
return r.payload
43+
return r.payload
44+
45+
def reissue_instance_certificate(server: server) -> bool:
46+
'''Deletes and reissues the UAG instance certificate object in the UAG certificate store.
47+
This is the UAG instance certificate that are used by UAG for trust purposes in the UA security model.
48+
49+
:param server: instance of the `server` class
50+
51+
:return: True - If a "HTTP 200 - OK" is received from Kepware server
52+
53+
:raises KepHTTPError: If urllib provides an HTTPError
54+
:raises KepURLError: If urllib provides an URLError
55+
'''
56+
r = server._config_del(server.url + _create_url_cert(_INTER_TYPE.CERTS, INSTANCE_CERTIFICATE))
57+
if r.code == 200: return True
58+
else:
59+
raise KepHTTPError(r.url, r.code, r.msg, r.hdrs, r.payload)

0 commit comments

Comments
 (0)