Skip to content

Commit 6a220bd

Browse files
author
Agathe Guillemot
committed
Add methods to list stages/delete published items
1 parent c1ed433 commit 6a220bd

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

dataikuapi/dss/apideployer.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ def create_deployment(self, deployment_id, service_id, infra_id, version):
5656
self.client._perform_json("POST", "/api-deployer/deployments", body=settings)
5757
return self.get_deployment(deployment_id)
5858

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+
5968
def list_infras(self, as_objects=True):
6069
"""
6170
Lists deployment infrastructures on the API Deployer
@@ -332,6 +341,7 @@ def save(self):
332341
"PUT", "/api-deployer/deployments/%s/settings" % (self.deployment_id),
333342
body = self.settings)
334343

344+
335345
class DSSAPIDeployerDeploymentStatus(object):
336346
"""The status of an API Deployer deployment.
337347
@@ -387,7 +397,6 @@ def get_health_messages(self):
387397
return self.heavy_status["healthMessages"]
388398

389399

390-
391400
###############################################
392401
# Published Service
393402
###############################################
@@ -440,6 +449,15 @@ def get_settings(self):
440449

441450
return DSSAPIDeployerServiceSettings(self.client, self.service_id, settings)
442451

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+
443461

444462
class DSSAPIDeployerServiceSettings(object):
445463
"""The settings of an API Deployer Service.
@@ -466,6 +484,7 @@ def save(self):
466484
"PUT", "/api-deployer/services/%s/settings" % (self.service_id),
467485
body = self.settings)
468486

487+
469488
class DSSAPIDeployerServiceStatus(object):
470489
"""The status of an API Deployer Service.
471490

dataikuapi/dss/projectdeployer.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ def create_deployment(self, deployment_id, project_key, infra_id, bundle_id):
5555
self.client._perform_json("POST", "/project-deployer/deployments", body=settings)
5656
return self.get_deployment(deployment_id)
5757

58+
def list_stages(self):
59+
"""
60+
Lists infrastructure stages of the Project Deployer
61+
62+
:rtype: a list of dict. Each dict contains a field "id" for the stage identifier and "desc" for its description.
63+
:rtype: list
64+
"""
65+
return self.client._perform_json("GET", "/project-deployer/stages")
66+
5867
def list_infras(self, as_objects=True):
5968
"""
6069
Lists deployment infrastructures on the Project Deployer
@@ -393,6 +402,14 @@ def get_settings(self):
393402

394403
return DSSProjectDeployerProjectSettings(self.client, self.project_key, settings)
395404

405+
def delete(self):
406+
"""
407+
Deletes this project
408+
409+
You may only delete a project if it has no deployments on it anymore.
410+
"""
411+
return self.client._perform_empty(
412+
"DELETE", "/project-deployer/projects/%s" % (self.project_key))
396413

397414
class DSSProjectDeployerProjectSettings(object):
398415
"""The settings of a published project.

0 commit comments

Comments
 (0)