Skip to content

Commit e370c9e

Browse files
committed
More doc
1 parent d8e2057 commit e370c9e

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

dataikuapi/dss/apiservice.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
import json
22

33
class DSSAPIServiceSettings(object):
4+
"""
5+
The settings of an API Service in the API Designer
6+
7+
Do not create this directly, use :meth:`DSSAPIService.get_settings`
8+
"""
49
def __init__(self, client, project_key, service_id, settings):
510
self.client = client
611
self.project_key = project_key
712
self.service_id = service_id
813
self.settings = settings
914

15+
def get_raw(self):
16+
"""
17+
Gets the raw settings of this API Service. This returns a reference to the raw settings, not a copy,
18+
so changes made to the returned object will be reflected when saving.
19+
20+
:rtype: dict
21+
"""
22+
return self.settings
23+
1024
def add_prediction_endpoint(self, endpoint_id, saved_model_id):
25+
"""Adds a new "visual prediction" endpoint to this API service
26+
27+
:param str endpoint_id: Identifier of the new endpoint to create
28+
:param str saved_model_id: Identifier of the saved model (deployed to Flow) to use
29+
"""
1130
self.settings["endpoints"].append({
1231
"id" : endpoint_id,
1332
"type" : "STD_PREDICTION",
@@ -16,15 +35,16 @@ def add_prediction_endpoint(self, endpoint_id, saved_model_id):
1635

1736
def save(self):
1837
"""Saves back these settings to the API Service"""
19-
print("SAVING: %s" % json.dumps(self.settings, indent=2))
2038
self.client._perform_empty(
2139
"PUT", "/projects/%s/apiservices/%s/settings" % (self.project_key, self.service_id),
2240
body = self.settings)
2341

2442

2543
class DSSAPIService(object):
2644
"""
27-
An API Service on the DSS instance
45+
An API Service from the API Designer on the DSS instance
46+
47+
Do not create this directly, use :meth:`dataikuapi.dss.project.DSSProject.get_api_service`
2848
"""
2949
def __init__(self, client, project_key, service_id):
3050
self.client = client
@@ -40,24 +60,27 @@ def get_settings(self):
4060

4161
def list_packages(self):
4262
"""
43-
List the packages of this API services
63+
List the versions of this API service
4464
45-
Returns:
46-
the list of API service packages, each one as a JSON object
65+
:returns: a list of dictionaries, with one item per version.
66+
Each dictionary contains at least a 'id' field which is the version identifier
67+
:rtype: list of dict
4768
"""
4869
return self.client._perform_json(
4970
"GET", "/projects/%s/apiservices/%s/packages" % (self.project_key, self.service_id))
5071

5172
def create_package(self, package_id):
5273
"""
53-
Prepare a package of this API service
74+
Create a new version of this API service
75+
76+
:param str package_id: Identifier of the new version to create
5477
"""
5578
return self.client._perform_empty(
5679
"POST", "/projects/%s/apiservices/%s/packages/%s" % (self.project_key, self.service_id, package_id))
5780

5881
def delete_package(self, package_id):
5982
"""
60-
Delete a package of this API service
83+
Delete a version of this API service
6184
"""
6285
return self.client._perform_empty(
6386
"DELETE", "/projects/%s/apiservices/%s/packages/%s" % (self.project_key, self.service_id, package_id))

dataikuapi/dss/project.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,11 @@ def list_api_services(self):
472472

473473
def create_api_service(self, service_id):
474474
"""
475-
Create a new API service, and returns a handle to interact with it
475+
Create a new API service, and returns a handle to interact with it. The newly-created
476+
service does not have any endpoint.
476477
477478
:param str service_id: the ID of the API service to create
478-
:returns: A :class:`dataikuapi.dss.dataset.DSSAPIService` API Service handle
479+
:returns: A :class:`~dataikuapi.dss.dataset.DSSAPIService` API Service handle
479480
"""
480481
self.client._perform_empty(
481482
"POST", "/projects/%s/apiservices/%s" % (self.project_key, service_id))
@@ -484,17 +485,14 @@ def create_api_service(self, service_id):
484485

485486
def get_api_service(self, service_id):
486487
"""
487-
Get a handle to interact with a specific API service
488+
Get a handle to interact with a specific API Service from the API Designer
488489
489-
Args:
490-
service_id: the ID of the desired API service
491-
492-
Returns:
493-
A :class:`dataikuapi.dss.dataset.DSSAPIService` API Service handle
490+
:param str service_id: The identifier of the API Designer API Service to retrieve
491+
:returns: A handle to interact with this API Service
492+
:rtype: :class:`~dataikuapi.dss.dataset.DSSAPIService` API Service handle
494493
"""
495494
return DSSAPIService(self.client, self.project_key, service_id)
496495

497-
498496
########################################################
499497
# Bundles / Export (Design node)
500498
########################################################

0 commit comments

Comments
 (0)