Skip to content

Commit a971a96

Browse files
author
Thibaud Baas
committed
FM Tenant: Update license
1 parent d7ceed6 commit a971a96

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

dataikuapi/fm/tenant.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
class FMCloudCredentials(object):
23
"""
34
A Tenant Cloud Credentials in the FM instance
@@ -9,6 +10,36 @@ def __init__(self, client, cloud_credentials):
910
def set_cmk_key(self, cmk_key_id):
1011
self.cloud_credentials['awsCMKId'] = cmk_key_id
1112

13+
def set_static_license(self, license_file=None, license_string=None):
14+
"""
15+
Set a default static license for the DSS instances
16+
17+
Requires either a license_file or a license_string
18+
19+
:param str license_file: Optional, load the license from a json file
20+
:param str license_string: Optional, load the license from a json string
21+
"""
22+
if license_file is not None:
23+
with open(license_file) as json_file:
24+
license = json.load(json_file)
25+
elif license_string is not None:
26+
license = json.load(license_string)
27+
else:
28+
raise ValueError("a valid license_file or license_string needs to be provided")
29+
self.cloud_credentials['licenseMode'] = 'STATIC'
30+
self.cloud_credentials['license'] = json.dumps(license, indent=2)
31+
32+
def set_automatically_updated_license(self, license_token):
33+
"""
34+
Set an automatically updated license for the DSS instances
35+
36+
:param str license_token: License token
37+
"""
38+
if license_token is None:
39+
raise ValueError("a valid license_token needs to be provided")
40+
self.cloud_credentials['licenseMode'] = 'AUTO_UPDATE'
41+
self.cloud_credentials['licenseToken'] = license_token
42+
1243
def save(self):
1344
"""Saves back the settings to the project"""
1445

0 commit comments

Comments
 (0)