11import json
22
33class 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
2543class 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 ))
0 commit comments