1
1
import json
2
2
from .future import DSSFuture
3
-
3
+ from .. utils import CallableStr
4
4
5
5
class DSSAPIDeployer (object ):
6
6
"""
@@ -60,7 +60,7 @@ def list_stages(self):
60
60
"""
61
61
Lists infrastructure stages of the API Deployer
62
62
63
- :rtype: a list of dict. Each dict contains a field "id" for the stage identifier and "desc" for its description.
63
+ :rtype: list of dict. Each dict contains a field "id" for the stage identifier and "desc" for its description.
64
64
:rtype: list
65
65
"""
66
66
return self .client ._perform_json ("GET" , "/api-deployer/stages" )
@@ -152,16 +152,27 @@ def get_service(self, service_id):
152
152
153
153
class DSSAPIDeployerInfra (object ):
154
154
"""
155
- A Deployment infrastructure on the API Deployer
155
+ An API Deployer infrastructure.
156
156
157
157
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployer.get_infra`
158
158
"""
159
159
def __init__ (self , client , infra_id ):
160
160
self .client = client
161
161
self .infra_id = infra_id
162
162
163
+ @property
163
164
def id (self ):
164
- return self .infra_id
165
+ return CallableStr (self .infra_id )
166
+
167
+ def get_status (self ):
168
+ """
169
+ Returns status information about this infrastructure
170
+
171
+ :rtype: :class:`dataikuapi.dss.apideployer.DSSAPIDeployerInfraStatus`
172
+ """
173
+ light = self .client ._perform_json ("GET" , "/api-deployer/infras/%s" % (self .infra_id ))
174
+
175
+ return DSSAPIDeployerInfraStatus (self .client , self .infra_id , light )
165
176
166
177
def get_settings (self ):
167
178
"""
@@ -186,7 +197,8 @@ def delete(self):
186
197
187
198
188
199
class DSSAPIDeployerInfraSettings (object ):
189
- """The settings of an API Deployer Infra.
200
+ """
201
+ The settings of an API Deployer infrastructure
190
202
191
203
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployerInfra.get_settings`
192
204
"""
@@ -238,6 +250,35 @@ def save(self):
238
250
body = self .settings )
239
251
240
252
253
+ class DSSAPIDeployerInfraStatus (object ):
254
+ """
255
+ The status of an API Deployer infrastructure.
256
+
257
+ Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployerInfra.get_status`
258
+ """
259
+ def __init__ (self , client , infra_id , light_status ):
260
+ self .client = client
261
+ self .infra_id = infra_id
262
+ self .light_status = light_status
263
+
264
+ def get_deployments (self ):
265
+ """
266
+ Returns the deployments that are deployed on this infrastructure
267
+
268
+ :returns: a list of deployments
269
+ :rtype: list of :class:`dataikuapi.dss.apideployer.DSSAPIDeployerDeployment`
270
+ """
271
+ return [DSSAPIDeployerDeployment (self .client , deployment ["id" ]) for deployment in self .light_status ["deployments" ]]
272
+
273
+ def get_raw (self ):
274
+ """
275
+ Gets the raw status information. This returns a dictionary with various information about the infrastructure
276
+
277
+ :rtype: dict
278
+ """
279
+ return self .light_status
280
+
281
+
241
282
###############################################
242
283
# Deployments
243
284
###############################################
@@ -252,11 +293,13 @@ def __init__(self, client, deployment_id):
252
293
self .client = client
253
294
self .deployment_id = deployment_id
254
295
296
+ @property
255
297
def id (self ):
256
- return self .deployment_id
298
+ return CallableStr ( self .deployment_id )
257
299
258
300
def get_status (self ):
259
- """Returns status information about this deployment
301
+ """
302
+ Returns status information about this deployment
260
303
261
304
:rtype: dataikuapi.dss.apideployer.DSSAPIDeployerDeploymentStatus
262
305
"""
@@ -302,7 +345,8 @@ def delete(self):
302
345
303
346
304
347
class DSSAPIDeployerDeploymentSettings (object ):
305
- """The settings of an API Deployer deployment.
348
+ """
349
+ The settings of an API Deployer deployment.
306
350
307
351
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployerDeployment.get_settings`
308
352
"""
@@ -321,7 +365,9 @@ def get_raw(self):
321
365
return self .settings
322
366
323
367
def set_enabled (self , enabled ):
324
- """Enables or disables this deployment"""
368
+ """
369
+ Enables or disables this deployment
370
+ """
325
371
self .settings ["enabled" ] = enabled
326
372
327
373
def set_single_version (self , version ):
@@ -336,14 +382,17 @@ def set_single_version(self, version):
336
382
}
337
383
338
384
def save (self ):
339
- """Saves back these settings to the deployment"""
385
+ """
386
+ Saves back these settings to the deployment
387
+ """
340
388
self .client ._perform_empty (
341
389
"PUT" , "/api-deployer/deployments/%s/settings" % (self .deployment_id ),
342
390
body = self .settings )
343
391
344
392
345
393
class DSSAPIDeployerDeploymentStatus (object ):
346
- """The status of an API Deployer deployment.
394
+ """
395
+ The status of an API Deployer deployment.
347
396
348
397
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployerDeployment.get_status`
349
398
"""
@@ -365,12 +414,15 @@ def get_light(self):
365
414
def get_heavy (self ):
366
415
"""
367
416
Gets the 'heavy' (full) status. This returns a dictionary with various information about the deployment
417
+
368
418
:rtype: dict
369
419
"""
370
420
return self .heavy_status
371
421
372
422
def get_service_urls (self ):
373
- """Returns service-level URLs for this deployment (ie without the enpdoint-specific suffix)"""
423
+ """
424
+ Returns service-level URLs for this deployment (ie without the enpdoint-specific suffix)
425
+ """
374
426
375
427
if "deployedServiceId" in self .light_status ["deploymentBasicInfo" ]:
376
428
service_id = self .light_status ["deploymentBasicInfo" ]["deployedServiceId" ]
@@ -385,7 +437,8 @@ def get_service_urls(self):
385
437
raise ValueError ("PublicURL not available for this deployment. It might still be initializing" )
386
438
387
439
def get_health (self ):
388
- """Returns the health of this deployment as a string
440
+ """
441
+ Returns the health of this deployment as a string
389
442
390
443
:returns: HEALTHY if the deployment is working properly, various other status otherwise
391
444
:rtype: string
@@ -411,8 +464,9 @@ def __init__(self, client, service_id):
411
464
self .client = client
412
465
self .service_id = service_id
413
466
467
+ @property
414
468
def id (self ):
415
- return self .service_id
469
+ return CallableStr ( self .service_id )
416
470
417
471
def get_status (self ):
418
472
"""
@@ -452,6 +506,7 @@ def get_settings(self):
452
506
def delete_version (self , version ):
453
507
"""
454
508
Deletes a version from this service
509
+
455
510
:param string version: The version to delete
456
511
"""
457
512
self .client ._perform_empty (
@@ -468,7 +523,8 @@ def delete(self):
468
523
469
524
470
525
class DSSAPIDeployerServiceSettings (object ):
471
- """The settings of an API Deployer Service.
526
+ """
527
+ The settings of an API Deployer Service.
472
528
473
529
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployerService.get_settings`
474
530
"""
@@ -487,14 +543,17 @@ def get_raw(self):
487
543
return self .settings
488
544
489
545
def save (self ):
490
- """Saves back these settings to the API service"""
546
+ """
547
+ Saves back these settings to the API service
548
+ """
491
549
self .client ._perform_empty (
492
550
"PUT" , "/api-deployer/services/%s/settings" % (self .service_id ),
493
551
body = self .settings )
494
552
495
553
496
554
class DSSAPIDeployerServiceStatus (object ):
497
- """The status of an API Deployer Service.
555
+ """
556
+ The status of an API Deployer Service.
498
557
499
558
Do not create this directly, use :meth:`~dataikuapi.dss.apideployer.DSSAPIDeployerService.get_status`
500
559
"""
@@ -503,6 +562,20 @@ def __init__(self, client, service_id, light_status):
503
562
self .service_id = service_id
504
563
self .light_status = light_status
505
564
565
+ def get_deployments (self , infra_id = None ):
566
+ """
567
+ Returns the deployments that have been created from this published project
568
+
569
+ :param str infra_id: Identifier of an infra, allows to only keep in the returned list the deployments on this infra.
570
+ If not set, the list contains all the deployments using this published project, across every infra of the Project Deployer.
571
+
572
+ :returns: a list of deployments
573
+ :rtype: list of :class:`dataikuapi.dss.apideployer.DSSAPIDeployerDeployment`
574
+ """
575
+ if infra_id is None :
576
+ return [DSSAPIDeployerDeployment (self .client , deployment ["id" ]) for deployment in self .light_status ["deployments" ]]
577
+ return [DSSAPIDeployerDeployment (self .client , deployment ["id" ]) for deployment in self .light_status ["deployments" ] if infra_id == deployment ["infraId" ]]
578
+
506
579
def get_versions (self ):
507
580
"""
508
581
Returns the versions of this service that have been published on the API Service
@@ -517,6 +590,7 @@ def get_versions(self):
517
590
def get_raw (self ):
518
591
"""
519
592
Gets the raw status information. This returns a dictionary with various information about the service,
593
+
520
594
:rtype: dict
521
595
"""
522
596
return self .light_status
0 commit comments