Skip to content

Commit 08690bb

Browse files
committed
W-16337942: Allow existing functions to be updated to public without being redefined
1 parent fa7aab2 commit 08690bb

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

tabpy/tabpy_server/handlers/endpoint_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def delete(self, name):
9595
return
9696

9797
self.logger.log(logging.DEBUG, f"Processing DELETE for /endpoints/{name}")
98+
self.logger.log(logging.INFO, f"Processing DELETE for /endpoints/{name}")
9899

99100
try:
100101
endpoints = self.tabpy_state.get_endpoints(name)

tabpy/tabpy_server/management/state.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,36 @@ def delete_endpoint(self, name):
428428
logger.error(f"Unable to delete endpoint {e}")
429429
raise ValueError(f"Unable to delete endpoint: {e}")
430430

431+
432+
@state_lock
433+
def make_endpoint_public(self, name):
434+
"""
435+
Updates an existing endpoint on the TabPy Server to be public
436+
437+
Parameters
438+
----------
439+
name : str
440+
The name of the endpoint to be updated.
441+
442+
Returns
443+
-------
444+
updated endpoint object
445+
446+
"""
447+
if not name or name == "":
448+
raise ValueError("Name of the endpoint must be a valid string.")
449+
endpoints = self.get_endpoints()
450+
if name not in endpoints:
451+
raise ValueError(f"Endpoint {name} does not exist.")
452+
453+
endpoint_to_update = endpoints[name]
454+
455+
456+
self.update_endpoint(
457+
name,
458+
isPublic=True
459+
)
460+
431461
@property
432462
def name(self):
433463
"""

tabpy/tabpy_tools/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ def remove(self, name):
264264
Endpoint name to remove'''
265265
self._service.remove_endpoint(name)
266266

267+
def make_public(self, name):
268+
'''Makes an existing endpoint public.
269+
270+
Parameters
271+
----------
272+
name : str
273+
Endpoint name to make public'''
274+
275+
self._service.make_public(name)
276+
267277
def _gen_endpoint(self, name, obj, description, version=1, schema=None, isPublic=False):
268278
"""Generates an endpoint dict.
269279

tabpy/tabpy_tools/rest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def PUT(self, url, data, timeout=None):
117117
data = self._encode_request(data)
118118

119119
logger.info(f"PUT {url} with {data}")
120+
logger.log(logging.INFO, f"PUT {url} with {data}")
120121

121122
response = self.session.put(
122123
url,

tabpy/tabpy_tools/rest_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ def set_endpoint(self, endpoint):
216216
"""
217217
return self.service_client.PUT("endpoints/" + endpoint.name, endpoint.to_json())
218218

219+
def make_public(self, endpoint_name):
220+
"""Updates an existing endpoint to be public.
221+
222+
Parameters
223+
----------
224+
225+
endpoint_name : str
226+
227+
The name of the endpoint.
228+
"""
229+
self.service_client.PUT("endpoints/" + endpoint_name)
230+
219231
def remove_endpoint(self, endpoint_name):
220232
"""Deletes an endpoint through the management API.
221233

0 commit comments

Comments
 (0)