Skip to content

Commit d8e2057

Browse files
committed
API Deployer: add create_service and import_version
1 parent c0b15cb commit d8e2057

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

dataikuapi/dss/apideployer.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ def list_services(self, as_objects = True):
9595
else:
9696
return l
9797

98+
def create_service(self, service_id):
99+
"""
100+
Creates a new API Service on the API Deployer and returns the handle to interact with it.
101+
102+
:param str service_id: Identifier of the API Service to create
103+
:rtype: :class:`DSSAPIDeployerService`
104+
"""
105+
settings = {
106+
"serviceId" : service_id
107+
}
108+
self.client._perform_json("POST", "/api-deployer/services", body=settings)
109+
return self.get_service(service_id)
110+
98111
def get_service(self, service_id):
99112
"""
100113
Returns a handle to interact with a single service, as a :class:`DSSAPIDeployerService`
@@ -371,6 +384,17 @@ def get_status(self):
371384
light = self.client._perform_json("GET", "/api-deployer/services/%s" % (self.service_id))
372385
return DSSAPIDeployerServiceStatus(self.client, self.service_id, light)
373386

387+
def import_version(self, version_id, fp):
388+
"""
389+
Imports a new version for an API service from a file-like object pointing
390+
to a version package Zip file
391+
392+
:param string version_id: identifier of the new version
393+
:param string fp: A file-like object pointing to a version package Zip file
394+
"""
395+
return self.client._perform_empty("POST",
396+
"/api-deployer/services/%s/packages/%s" % (self.service_id, version_id), files={"file":fp})
397+
374398
def get_settings(self):
375399
"""
376400
Gets the settings of this service. If you want to modify the settings, you need to

0 commit comments

Comments
 (0)