Skip to content

Commit 336cc0c

Browse files
author
Agathe Guillemot
committed
Add infra status wrapper class
1 parent 04907d5 commit 336cc0c

File tree

2 files changed

+83
-5
lines changed

2 files changed

+83
-5
lines changed

dataikuapi/dss/apideployer.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def get_service(self, service_id):
152152

153153
class DSSAPIDeployerInfra(object):
154154
"""
155-
A Deployment infrastructure on the API Deployer
155+
An API Deployer infrastructure.
156156
157157
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployer.get_infra`
158158
"""
@@ -163,6 +163,16 @@ def __init__(self, client, infra_id):
163163
def id(self):
164164
return self.infra_id
165165

166+
def get_status(self):
167+
"""
168+
Returns status information about this infrastructure
169+
170+
:rtype: a :class:`dataikuapi.dss.apideployer.DSSAPIDeployerInfraStatus`
171+
"""
172+
light = self.client._perform_json("GET", "/api-deployer/infras/%s" % (self.infra_id))
173+
174+
return DSSAPIDeployerInfraStatus(self.client, self.infra_id, light)
175+
166176
def get_settings(self):
167177
"""
168178
Gets the settings of this infra. If you want to modify the settings, you need to
@@ -186,7 +196,8 @@ def delete(self):
186196

187197

188198
class DSSAPIDeployerInfraSettings(object):
189-
"""The settings of an API Deployer Infra.
199+
"""
200+
The settings of an API Deployer infrastructure
190201
191202
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployerInfra.get_settings`
192203
"""
@@ -238,6 +249,34 @@ def save(self):
238249
body = self.settings)
239250

240251

252+
class DSSAPIDeployerInfraStatus(object):
253+
"""
254+
The status of an API Deployer infrastructure.
255+
256+
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployerInfra.get_status`
257+
"""
258+
def __init__(self, client, infra_id, light_status):
259+
self.client = client
260+
self.infra_id = infra_id
261+
self.light_status = light_status
262+
263+
def list_deployments(self):
264+
"""
265+
Returns the deployments that are deployed on this infrastructure
266+
267+
:returns: a list of deployments
268+
:rtype: list of :class:`dataikuapi.dss.apideployer.DSSAPIDeployerDeployment`
269+
"""
270+
return [DSSAPIDeployerDeployment(self.client, deployment.id) for deployment in self.light_status["deployments"]]
271+
272+
def get_raw(self):
273+
"""
274+
Gets the raw status information. This returns a dictionary with various information about the infrastructure
275+
:rtype: dict
276+
"""
277+
return self.light_status
278+
279+
241280
###############################################
242281
# Deployments
243282
###############################################

dataikuapi/dss/projectdeployer.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def upload_bundle(self, fp, project_key=None):
177177

178178
class DSSProjectDeployerInfra(object):
179179
"""
180-
A Deployment infrastructure on the Project Deployer
180+
An Automation infrastructure on the Project Deployer
181181
182182
Do not create this directly, use :meth:`~dataikuapi.dss.projectdeployer.DSSProjectDeployer.get_infra`
183183
"""
@@ -188,6 +188,16 @@ def __init__(self, client, infra_id):
188188
def id(self):
189189
return self.infra_id
190190

191+
def get_status(self):
192+
"""
193+
Returns status information about this infrastructure
194+
195+
:rtype: a :class:`dataikuapi.dss.projectdeployer.DSSProjectDeployerInfraStatus`
196+
"""
197+
light = self.client._perform_json("GET", "/project-deployer/infras/%s" % (self.infra_id))
198+
199+
return DSSProjectDeployerInfraStatus(self.client, self.infra_id, light)
200+
191201
def get_settings(self):
192202
"""
193203
Gets the settings of this infra. If you want to modify the settings, you need to
@@ -211,7 +221,8 @@ def delete(self):
211221

212222

213223
class DSSProjectDeployerInfraSettings(object):
214-
"""The settings of a Project Deployer Infra.
224+
"""
225+
The settings of an Automation infrastructure.
215226
216227
Do not create this directly, use :meth:`~dataikuapi.dss.projectdeployer.DSSProjectDeployerInfra.get_settings`
217228
"""
@@ -236,6 +247,33 @@ def save(self):
236247
body = self.settings)
237248

238249

250+
class DSSProjectDeployerInfraStatus(object):
251+
"""
252+
The status of an Automation infrastructure.
253+
254+
Do not create this directly, use :meth:`~dataikuapi.dss.projectdeployer.DSSProjectDeployerInfra.get_status`
255+
"""
256+
def __init__(self, client, infra_id, light_status):
257+
self.client = client
258+
self.infra_id = infra_id
259+
self.light_status = light_status
260+
261+
def list_deployments(self):
262+
"""
263+
Returns the deployments that are deployed on this infrastructure
264+
265+
:returns: a list of deployments
266+
:rtype: list of :class:`dataikuapi.dss.projectdeployer.DSSProjectDeployerDeployment`
267+
"""
268+
return [DSSProjectDeployerDeployment(self.client, deployment.id) for deployment in self.light_status["deployments"]]
269+
270+
def get_raw(self):
271+
"""
272+
Gets the raw status information. This returns a dictionary with various information about the infrastructure
273+
:rtype: dict
274+
"""
275+
return self.light_status
276+
239277
###############################################
240278
# Deployments
241279
###############################################
@@ -444,6 +482,7 @@ def delete(self):
444482
return self.client._perform_empty(
445483
"DELETE", "/project-deployer/projects/%s" % (self.project_key))
446484

485+
447486
class DSSProjectDeployerProjectSettings(object):
448487
"""The settings of a published project.
449488
@@ -511,4 +550,4 @@ def get_raw(self):
511550
Gets the raw status information. This returns a dictionary with various information about the project
512551
:rtype: dict
513552
"""
514-
return self.light_status
553+
return self.light_status

0 commit comments

Comments
 (0)