Skip to content

Commit dc5e5dd

Browse files
authored
Merge pull request #217 from dataiku/perso/aqueru/govern-bundle
Add support for bundle governance
2 parents c84bec6 + 14f6c94 commit dc5e5dd

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

dataikuapi/dss/apideployer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def create_infra(self, infra_id, stage, type, govern_check_policy="NO_CHECK"):
9696
"id": infra_id,
9797
"stage": stage,
9898
"type": type,
99-
"govern_check_policy": govern_check_policy,
99+
"governCheckPolicy": govern_check_policy,
100100
}
101101
self.client._perform_json("POST", "/api-deployer/infras", body=settings)
102102
return self.get_infra(infra_id)

dataikuapi/dss/projectdeployer.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_deployment(self, deployment_id):
3636
return DSSProjectDeployerDeployment(self.client, deployment_id)
3737

3838
def create_deployment(self, deployment_id, project_key, infra_id, bundle_id,
39-
deployed_project_key=None, project_folder_id=None):
39+
deployed_project_key=None, project_folder_id=None, ignore_warnings=False):
4040
"""
4141
Creates a deployment and returns the handle to interact with it. The returned deployment
4242
is not yet started and you need to call :meth:`~DSSProjectDeployerDeployment.start_update`
@@ -50,6 +50,7 @@ def create_deployment(self, deployment_id, project_key, infra_id, bundle_id,
5050
published project
5151
:param str project_folder_id: The automation node project folder id to deploy this project into. If not set,
5252
the project will be created in the root folder
53+
:param boolean ignore_warnings: ignore warnings concerning the governance status of the bundle to deploy
5354
:rtype: :class:`DSSProjectDeployerDeployment`
5455
"""
5556
settings = {
@@ -62,7 +63,7 @@ def create_deployment(self, deployment_id, project_key, infra_id, bundle_id,
6263
settings["deployedProjectKey"] = deployed_project_key
6364
if project_folder_id:
6465
settings["projectFolderId"] = project_folder_id
65-
self.client._perform_json("POST", "/project-deployer/deployments", body=settings)
66+
self.client._perform_json("POST", "/project-deployer/deployments", params={"ignoreWarnings": ignore_warnings}, body=settings)
6667
return self.get_deployment(deployment_id)
6768

6869
def list_stages(self):
@@ -90,17 +91,19 @@ def list_infras(self, as_objects=True):
9091
else:
9192
return l
9293

93-
def create_infra(self, infra_id, stage):
94+
def create_infra(self, infra_id, stage, govern_check_policy="NO_CHECK"):
9495
"""
9596
Creates a new infrastructure on the Project Deployer and returns the handle to interact with it.
9697
9798
:param str infra_id: Unique Identifier of the infra to create
9899
:param str stage: Infrastructure stage
100+
:param str govern_check_policy: PREVENT, WARN, or NO_CHECK depending if the deployer will check wether the bundle deployed on this infrastructure has to be managed and approved in Dataiku Govern
99101
:rtype: :class:`DSSProjectDeployerInfra`
100102
"""
101103
settings = {
102104
"id": infra_id,
103-
"stage": stage
105+
"stage": stage,
106+
"governCheckPolicy": govern_check_policy,
104107
}
105108
self.client._perform_json("POST", "/project-deployer/infras", body=settings)
106109
return self.get_infra(infra_id)
@@ -309,6 +312,15 @@ def get_status(self):
309312

310313
return DSSProjectDeployerDeploymentStatus(self.client, self.deployment_id, light, heavy)
311314

315+
def get_governance_status(self, bundle_id=""):
316+
"""
317+
Returns the governance status about this deployment if applicable
318+
319+
:param str bundle_id: (Optional) The ID of a specific bundle of the published project to get status from. If empty, consider the bundle currently used in the deployment.
320+
:rtype: dict InforMessages containing the governance status
321+
"""
322+
return self.client._perform_json("GET", "/project-deployer/deployments/%s/governance-status" % (self.deployment_id), params={ "bundleId": bundle_id })
323+
312324
def get_settings(self):
313325
"""
314326
Gets the settings of this deployment. If you want to modify the settings, you need to
@@ -377,12 +389,15 @@ def bundle_id(self):
377389
def bundle_id(self, new_bundle_id):
378390
self.settings["bundleId"] = new_bundle_id
379391

380-
def save(self):
392+
def save(self, ignore_warnings=False):
381393
"""
382394
Saves back these settings to the deployment
395+
396+
:param boolean ignore_warnings: ignore warnings concerning the governance status of the bundle to deploy
383397
"""
384398
self.client._perform_empty(
385399
"PUT", "/project-deployer/deployments/%s/settings" % (self.deployment_id),
400+
params = { "ignoreWarnings" : ignore_warnings },
386401
body = self.settings)
387402

388403

0 commit comments

Comments
 (0)