11import json
22from .future import DSSFuture
33
4+
45class 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
@@ -121,7 +131,7 @@ def create_service(self, service_id):
121131 :rtype: :class:`DSSAPIDeployerService`
122132 """
123133 settings = {
124- "serviceId " : service_id
134+ "publishedServiceId " : service_id
125135 }
126136 self .client ._perform_json ("POST" , "/api-deployer/services" , body = settings )
127137 return self .get_service (service_id )
@@ -331,6 +341,7 @@ def save(self):
331341 "PUT" , "/api-deployer/deployments/%s/settings" % (self .deployment_id ),
332342 body = self .settings )
333343
344+
334345class 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###############################################
@@ -414,16 +424,15 @@ def get_status(self):
414424 light = self .client ._perform_json ("GET" , "/api-deployer/services/%s" % (self .service_id ))
415425 return DSSAPIDeployerServiceStatus (self .client , self .service_id , light )
416426
417- def import_version (self , version_id , fp ):
427+ def import_version (self , fp ):
418428 """
419429 Imports a new version for an API service from a file-like object pointing
420430 to a version package Zip file
421431
422- :param string version_id: identifier of the new version
423432 :param string fp: A file-like object pointing to a version package Zip file
424433 """
425434 return self .client ._perform_empty ("POST" ,
426- "/api-deployer/services/%s/packages/%s " % (self .service_id , version_id ), files = {"file" :fp })
435+ "/api-deployer/services/%s/versions " % (self .service_id ), files = {"file" :fp })
427436
428437 def get_settings (self ):
429438 """
@@ -440,6 +449,23 @@ def get_settings(self):
440449
441450 return DSSAPIDeployerServiceSettings (self .client , self .service_id , settings )
442451
452+ def delete_version (self , version ):
453+ """
454+ Deletes a version from this service
455+ :param string version: The version to delete
456+ """
457+ self .client ._perform_empty (
458+ "DELETE" , "/api-deployer/services/%s/versions/%s" % (self .service_id , version ))
459+
460+ def delete (self ):
461+ """
462+ Deletes this service
463+
464+ You may only delete a service if it has no deployments on it anymore.
465+ """
466+ return self .client ._perform_empty (
467+ "DELETE" , "/api-deployer/services/%s" % (self .service_id ))
468+
443469
444470class DSSAPIDeployerServiceSettings (object ):
445471 """The settings of an API Deployer Service.
@@ -466,6 +492,7 @@ def save(self):
466492 "PUT" , "/api-deployer/services/%s/settings" % (self .service_id ),
467493 body = self .settings )
468494
495+
469496class DSSAPIDeployerServiceStatus (object ):
470497 """The status of an API Deployer Service.
471498
0 commit comments