(cls, variant, api, name, def_dict,
                         wire_name, parent)
return schema
Creates a variant type.
Creates a variant type.
Creates a variant type .
def _CreateVariantType(cls, variant, api, name, def_dict,
                         wire_name, parent):
    """Creates a variant type."""
    variants = collections.OrderedDict()
    schema = cls(api, name, def_dict, parent=parent)
    if wire_name:
      schema.SetTemplateValue('wireName', wire_name)
    discriminant = variant['discriminant']

    # Walk over variants building the variant map and register
    # variant info on the api.
    for variant_entry in variant['map']:
      discriminant_value = variant_entry['type_value']
      variant_schema = api.DataTypeFromJson(variant_entry, name, parent=parent)
      variants[discriminant_value] = variant_schema
      # Set variant info. We get the original wire name from the JSON properties
      # via '$ref' it is not currently accessible via variant_schema.
      api.SetVariantInfo(variant_entry.get('$ref'), discriminant,
                         discriminant_value, schema)

    prop = Property(api, schema, discriminant, {'type': 'string'},
                    key_for_variants=variants)
    schema.SetTemplateValue('is_variant_base', True)
    schema.SetTemplateValue('discriminant', prop)
    schema.SetTemplateValue('properties', [prop])
    return schema
def _CreateVariantType ( cls , variant , api , name , def_dict , wire_name , parent ) : variants = collections . OrderedDict ( ) schema = cls ( api , name , def_dict , parent = parent ) if wire_name : schema . SetTemplateValue ( 'wireName' , wire_name ) discriminant = variant [ 'discriminant' ] # Walk over variants building the variant map and register # variant info on the api. for variant_entry in variant [ 'map' ] : discriminant_value = variant_entry [ 'type_value' ] variant_schema = api . DataTypeFromJson ( variant_entry , name , parent = parent ) variants [ discriminant_value ] = variant_schema # Set variant info. We get the original wire name from the JSON properties # via '$ref' it is not currently accessible via variant_schema. api . SetVariantInfo ( variant_entry . get ( '$ref' ) , discriminant , discriminant_value , schema ) prop = Property ( api , schema , discriminant , { 'type' : 'string' } , key_for_variants = variants ) schema . SetTemplateValue ( 'is_variant_base' , True ) schema . SetTemplateValue ( 'discriminant' , prop ) schema . SetTemplateValue ( 'properties' , [ prop ] ) return schema