@@ -12,29 +12,27 @@ def __init__(self, client, cloud_credentials):
1212
1313 def set_cmk_key (self , cmk_key_id ):
1414 self .cloud_credentials ["awsCMKId" ] = cmk_key_id
15- self . save ()
15+ return self
1616
17- def set_static_license (self , license_file = None , license_string = None ):
17+ def set_static_license (self , license_file_path = None , license_string = None ):
1818 """
1919 Set a default static license for the DSS instances
2020
21- Requires either a license_file or a license_string
22-
23- :param str license_file: Optional, load the license from a json file
21+ :param str license_file_path: Optional, load the license from a json file
2422 :param str license_string: Optional, load the license from a json string
2523 """
26- if license_file is not None :
27- with open (license_file ) as json_file :
24+ if license_file_path is not None :
25+ with open (license_file_path ) as json_file :
2826 license = json .load (json_file )
2927 elif license_string is not None :
3028 license = json .loads (license_string )
3129 else :
3230 raise ValueError (
33- "a valid license_file or license_string needs to be provided"
31+ "a valid license_file_path or license_string needs to be provided"
3432 )
3533 self .cloud_credentials ["licenseMode" ] = "STATIC"
3634 self .cloud_credentials ["license" ] = json .dumps (license , indent = 2 )
37- self . save ()
35+ return self
3836
3937 def set_automatically_updated_license (self , license_token ):
4038 """
@@ -46,7 +44,7 @@ def set_automatically_updated_license(self, license_token):
4644 raise ValueError ("a valid license_token needs to be provided" )
4745 self .cloud_credentials ["licenseMode" ] = "AUTO_UPDATE"
4846 self .cloud_credentials ["licenseToken" ] = license_token
49- self . save ()
47+ return self
5048
5149 def set_authentication (self , authentication ):
5250 """
@@ -55,7 +53,7 @@ def set_authentication(self, authentication):
5553 :param object: a :class:`dataikuapi.fm.tenant.FMCloudAuthentication`
5654 """
5755 self .cloud_credentials .update (authentication )
58- self . save ()
56+ return self
5957
6058 def save (self ):
6159 """Saves back the settings to the project"""
@@ -70,57 +68,18 @@ class FMCloudTags(object):
7068 A Tenant Cloud Tags in the FM instance
7169 """
7270
73- def __init__ (self , client , tenant_id , cloud_tags ):
71+ def __init__ (self , client , cloud_tags ):
7472 self .client = client
75- self .tenant_id = tenant_id
7673 self .cloud_tags = json .loads (cloud_tags ["msg" ])
7774
78- def add_tag (self , key , value ):
79- """
80- Add a tag to the tenant
81-
82-
83- :param str key: Tag key
84- :param str value: Tag value
85- """
86- if key in self .cloud_tags :
87- raise Exception ("Key already exists" )
88- self .cloud_tags [key ] = value
89-
90- def update_tag (self , key , new_key = None , new_value = None ):
91- """
92- Update a tag key or value
93-
94-
95- :param str key: Key of the tag to update
96- :param str new_key: Optional, new key for the tag
97- :param str new_value: Optional, new value for the tag
98- """
99- if key not in self .cloud_tags :
100- raise Exception ("Key does not exists" )
101- if new_value :
102- self .cloud_tags [key ] = new_value
103- if new_key :
104- self .cloud_tags [new_key ] = self .cloud_tags [key ]
105- del self .cloud_tags [key ]
106-
107- def delete_tag (self , key ):
108- """
109- Delete a tag
110-
111-
112- :param str key: Key of the tag to delete
113- """
114- if key not in self .cloud_tags :
115- raise Exception ("Key does not exists" )
116- del self .cloud_tags [key ]
75+ @property
76+ def tags (self ):
77+ return self .cloud_tags
11778
11879 def save (self ):
11980 """Saves the tags on FM"""
12081
121- self .client ._perform_empty (
122- "PUT" , "/tenants/%s/cloud-tags" % (self .tenant_id ), body = self .cloud_tags
123- )
82+ self .client ._perform_tenant_empty ("PUT" , "/cloud-tags" , body = self .cloud_tags )
12483
12584
12685class FMCloudAuthentication (dict ):
0 commit comments