@@ -512,7 +512,7 @@ def create_meaning(self, id, label, type, description=None,
512512 :param id: the ID of the new meaning
513513 :param type: the type of the new meaning. Admissible values are 'DECLARATIVE', 'VALUES_LIST', 'VALUES_MAPPING' and 'PATTERN'
514514 :param description (optional): the description of the new meaning
515- :param values (optional): when type is 'VALUES_LIST', the list of values
515+ :param values (optional): when type is 'VALUES_LIST', the list of values, or a list of {'value':'the value', 'color':'an optional color'}
516516 :param mappings (optional): when type is 'VALUES_MAPPING', the mapping, as a list of objects with this
517517 structure: {'from': 'value_1', 'to': 'value_a'}
518518 :param pattern (optional): when type is 'PATTERN', the pattern
@@ -523,13 +523,25 @@ def create_meaning(self, id, label, type, description=None,
523523
524524 :returns: A :class:`dataikuapi.dss.meaning.DSSMeaning` meaning handle
525525 """
526+ def make_entry (v ):
527+ if isinstance (v , str ) or isinstance (v , unicode ):
528+ return {'value' :v }
529+ else :
530+ return v
531+ def make_mapping (v ):
532+ return {'from' :v .get ('from' , None ), 'to' :make_entry (v .get ('to' , None ))}
533+ entries = None
534+ if values is not None :
535+ entries = [make_entry (v ) for v in values ]
536+ if mappings is not None :
537+ mappings = [make_mapping (v ) for v in mappings ]
526538 resp = self ._perform_text (
527539 "POST" , "/meanings/" , body = {
528540 "id" : id ,
529541 "label" : label ,
530542 "type" : type ,
531543 "description" : description ,
532- "values " : values ,
544+ "entries " : entries ,
533545 "mappings" : mappings ,
534546 "pattern" : pattern ,
535547 "normalizationMode" : normalizationMode ,
0 commit comments