Skip to content

Commit 72b3646

Browse files
authored
Merge pull request #96 from dataiku/feature/dss90-project-deployer-public-api
Add Python client for Project deployer
2 parents 0b58fcf + 8c90b44 commit 72b3646

3 files changed

Lines changed: 502 additions & 4 deletions

File tree

dataikuapi/dss/apideployer.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
from .future import DSSFuture
33

4+
45
class DSSAPIDeployer(object):
56
"""
67
Handle to interact with the API Deployer.
@@ -10,7 +11,7 @@ class DSSAPIDeployer(object):
1011
def __init__(self, client):
1112
self.client = client
1213

13-
def list_deployments(self, as_objects = True):
14+
def list_deployments(self, as_objects=True):
1415
"""
1516
Lists deployments on the API Deployer
1617
@@ -55,7 +56,16 @@ def create_deployment(self, deployment_id, service_id, infra_id, version):
5556
self.client._perform_json("POST", "/api-deployer/deployments", body=settings)
5657
return self.get_deployment(deployment_id)
5758

58-
def list_infras(self, as_objects = True):
59+
def list_stages(self):
60+
"""
61+
Lists infrastructure stages of the API Deployer
62+
63+
:rtype: a list of dict. Each dict contains a field "id" for the stage identifier and "desc" for its description.
64+
:rtype: list
65+
"""
66+
return self.client._perform_json("GET", "/api-deployer/stages")
67+
68+
def list_infras(self, as_objects=True):
5969
"""
6070
Lists deployment infrastructures on the API Deployer
6171
@@ -97,7 +107,7 @@ def get_infra(self, infra_id):
97107
"""
98108
return DSSAPIDeployerInfra(self.client, infra_id)
99109

100-
def list_services(self, as_objects = True):
110+
def list_services(self, as_objects=True):
101111
"""
102112
Lists API services on the API Deployer
103113
@@ -331,6 +341,7 @@ def save(self):
331341
"PUT", "/api-deployer/deployments/%s/settings" % (self.deployment_id),
332342
body = self.settings)
333343

344+
334345
class DSSAPIDeployerDeploymentStatus(object):
335346
"""The status of an API Deployer deployment.
336347
@@ -386,7 +397,6 @@ def get_health_messages(self):
386397
return self.heavy_status["healthMessages"]
387398

388399

389-
390400
###############################################
391401
# Published Service
392402
###############################################
@@ -439,6 +449,15 @@ def get_settings(self):
439449

440450
return DSSAPIDeployerServiceSettings(self.client, self.service_id, settings)
441451

452+
def delete(self):
453+
"""
454+
Deletes this service
455+
456+
You may only delete a service if it has no deployments on it anymore.
457+
"""
458+
return self.client._perform_empty(
459+
"DELETE", "/api-deployer/services/%s" % (self.service_id))
460+
442461

443462
class DSSAPIDeployerServiceSettings(object):
444463
"""The settings of an API Deployer Service.
@@ -465,6 +484,7 @@ def save(self):
465484
"PUT", "/api-deployer/services/%s/settings" % (self.service_id),
466485
body = self.settings)
467486

487+
468488
class DSSAPIDeployerServiceStatus(object):
469489
"""The status of an API Deployer Service.
470490

0 commit comments

Comments
 (0)