Skip to content

Commit f921a22

Browse files
committed
WIP
2 parents 08690bb + fc80078 commit f921a22

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

tabpy/tabpy_server/handlers/management_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _add_or_update_endpoint(self, action, name, version, request_data):
8484
target = request_data.get("target", None)
8585
schema = request_data.get("schema", None)
8686
src_path = request_data.get("src_path", None)
87-
isPublic = request_data.get("isPublic", None)
87+
is_public = request_data.get("is_public", None)
8888
target_path = get_query_object_path(
8989
self.settings[SettingsParameters.StateFilePath], name, version
9090
)
@@ -118,7 +118,7 @@ def _add_or_update_endpoint(self, action, name, version, request_data):
118118
dependencies=dependencies,
119119
target=target,
120120
schema=schema,
121-
isPublic=isPublic,
121+
is_public=is_public,
122122
)
123123
else:
124124
self.tabpy_state.update_endpoint(
@@ -131,7 +131,7 @@ def _add_or_update_endpoint(self, action, name, version, request_data):
131131
target=target,
132132
schema=schema,
133133
version=version,
134-
isPublic=isPublic,
134+
is_public=is_public,
135135
)
136136

137137
except Exception as e:

tabpy/tabpy_server/management/state.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ def _check_and_set_dependencies(self, dependencies, defaultValue):
187187

188188
return dependencies
189189

190-
def _check_and_set_is_public(self, isPublic, defaultValue):
191-
if isPublic is None:
190+
def _check_and_set_is_public(self, is_public, defaultValue):
191+
if is_public is None:
192192
return defaultValue
193193

194-
return isPublic
194+
return is_public
195195

196196
@state_lock
197197
def add_endpoint(
@@ -204,7 +204,7 @@ def add_endpoint(
204204
target=None,
205205
dependencies=None,
206206
schema=None,
207-
isPublic=None,
207+
is_public=None,
208208
):
209209
"""
210210
Add a new endpoint to the TabPy.
@@ -238,7 +238,7 @@ def add_endpoint(
238238
docstring, "-- no docstring found in query function --")
239239
endpoint_type = self._check_and_set_endpoint_type(endpoint_type, None)
240240
dependencies = self._check_and_set_dependencies(dependencies, [])
241-
isPublic = self._check_and_set_is_public(isPublic, False)
241+
is_public = self._check_and_set_is_public(is_public, False)
242242

243243
self._check_target(target)
244244
if target and target not in endpoints:
@@ -254,7 +254,7 @@ def add_endpoint(
254254
"creation_time": int(time()),
255255
"last_modified_time": int(time()),
256256
"schema": schema,
257-
"isPublic": isPublic,
257+
"is_public": is_public,
258258
}
259259

260260
endpoints[name] = endpoint_info
@@ -298,7 +298,7 @@ def update_endpoint(
298298
target=None,
299299
dependencies=None,
300300
schema=None,
301-
isPublic=None,
301+
is_public=None,
302302
):
303303
"""
304304
Update an existing endpoint on the TabPy.
@@ -340,7 +340,7 @@ def update_endpoint(
340340
endpoint_type, endpoint_info["type"])
341341
dependencies = self._check_and_set_dependencies(
342342
dependencies, endpoint_info.get("dependencies", []))
343-
isPublic = self._check_and_set_is_public(isPublic, endpoint_info["isPublic"])
343+
is_public = self._check_and_set_is_public(is_public, endpoint_info["is_public"])
344344

345345
self._check_target(target)
346346
if target and target not in endpoints:
@@ -363,7 +363,7 @@ def update_endpoint(
363363
"creation_time": endpoint_info["creation_time"],
364364
"last_modified_time": int(time()),
365365
"schema": schema,
366-
"isPublic": isPublic,
366+
"is_public": is_public,
367367
}
368368

369369
endpoints[name] = endpoint_info
@@ -455,7 +455,7 @@ def make_endpoint_public(self, name):
455455

456456
self.update_endpoint(
457457
name,
458-
isPublic=True
458+
is_public=True
459459
)
460460

461461
@property

tabpy/tabpy_tools/client.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def get_endpoints(self, type=None):
174174
"last_modified_time": 1469511182,
175175
"type": "model",
176176
"target": null,
177-
"isPublic": True}
177+
"is_public": True}
178178
"add": {
179179
"description": "",
180180
"docstring": "-- no docstring found in query function --",
@@ -184,7 +184,7 @@ def get_endpoints(self, type=None):
184184
"last_modified_time": 1469505967,
185185
"type": "model",
186186
"target": null,
187-
"isPublic": False}
187+
"is_public": False}
188188
}
189189
"""
190190
return self._service.get_endpoints(type)
@@ -193,7 +193,7 @@ def _get_endpoint_upload_destination(self):
193193
"""Returns the endpoint upload destination."""
194194
return self._service.get_endpoint_upload_destination()["path"]
195195

196-
def deploy(self, name, obj, description="", schema=None, override=False, isPublic=False):
196+
def deploy(self, name, obj, description="", schema=None, override=False, is_public=False):
197197
"""Deploys a Python function as an endpoint in the server.
198198
199199
Parameters
@@ -222,7 +222,7 @@ def deploy(self, name, obj, description="", schema=None, override=False, isPubli
222222
RuntimeError. If True and there is already an endpoint with that
223223
name, it will deploy a new version on top of it.
224224
225-
isPublic : bool, optional
225+
is_public : bool, optional
226226
Whether a function should be public for viewing from within tableau. If
227227
False, function will not appear in the custom functions explorer within
228228
Tableau. If True, function will be visible ta anyone on a site with this
@@ -244,7 +244,7 @@ def deploy(self, name, obj, description="", schema=None, override=False, isPubli
244244

245245
version = endpoint.version + 1
246246

247-
obj = self._gen_endpoint(name, obj, description, version, schema, isPublic)
247+
obj = self._gen_endpoint(name, obj, description, version, schema, is_public)
248248

249249
self._upload_endpoint(obj)
250250

@@ -272,9 +272,10 @@ def make_public(self, name):
272272
name : str
273273
Endpoint name to make public'''
274274

275-
self._service.make_public(name)
275+
endpoint = self.get_endpoints().get(name)
276+
self._service.make_public(endpoint)
276277

277-
def _gen_endpoint(self, name, obj, description, version=1, schema=None, isPublic=False):
278+
def _gen_endpoint(self, name, obj, description, version=1, schema=None, is_public=False):
278279
"""Generates an endpoint dict.
279280
280281
Parameters
@@ -292,7 +293,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, isPublic
292293
version : int
293294
The version. Defaults to 1.
294295
295-
isPublic : bool
296+
is_public : bool
296297
True if function should be visible in the custom functions explorer
297298
within Tableau
298299
@@ -340,7 +341,7 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=None, isPublic
340341
"required_files": [],
341342
"required_packages": [],
342343
"schema": copy.copy(schema),
343-
"isPublic": isPublic,
344+
"is_public": is_public,
344345
}
345346

346347
def _upload_endpoint(self, obj):

tabpy/tabpy_tools/rest_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Endpoint(RESTObject):
4747
evaluator = RESTProperty(str)
4848
schema_version = RESTProperty(int)
4949
schema = RESTProperty(str)
50-
isPublic = RESTProperty(bool)
50+
is_public = RESTProperty(bool)
5151

5252
def __new__(cls, **kwargs):
5353
"""Dispatch to the appropriate class."""
@@ -68,7 +68,7 @@ def __eq__(self, other):
6868
and self.evaluator == other.evaluator
6969
and self.schema_version == other.schema_version
7070
and self.schema == other.schema
71-
and self.isPublic == other.isPublic
71+
and self.is_public == other.is_public
7272
)
7373

7474

@@ -216,17 +216,17 @@ 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):
219+
def make_public(self, endpoint):
220220
"""Updates an existing endpoint to be public.
221221
222222
Parameters
223223
----------
224224
225-
endpoint_name : str
225+
endpoint : Endpoint
226226
227-
The name of the endpoint.
227+
The endpoint to make public.
228228
"""
229-
self.service_client.PUT("endpoints/" + endpoint_name)
229+
self.service_client.PUT("endpoints/" + endpoint.name, endpoint.to_json())
230230

231231
def remove_endpoint(self, endpoint_name):
232232
"""Deletes an endpoint through the management API.

0 commit comments

Comments
 (0)