def IndexDefinitionToProto(app_id, index_definition):
 proto = entity_pb.CompositeIndex()
 proto.set_app_id(app_id)
 proto.set_id(0)
 proto.set_state(entity_pb.CompositeIndex.WRITE_ONLY)
 definition_proto = proto.mutable_definition()
 definition_proto.set_entity_type(index_definition.kind)
 definition_proto.set_ancestor(index_definition.ancestor)
 if (index_definition.properties is not None):
  is_geo = any(((x.mode == 'geospatial') for x in index_definition.properties))
  for prop in index_definition.properties:
   prop_proto = definition_proto.add_property()
   prop_proto.set_name(prop.name)
   if (prop.mode == 'geospatial'):
    prop_proto.set_mode(entity_pb.Index_Property.GEOSPATIAL)
   elif is_geo:
    pass
   elif prop.IsAscending():
    prop_proto.set_direction(entity_pb.Index_Property.ASCENDING)
   else:
    prop_proto.set_direction(entity_pb.Index_Property.DESCENDING)
 return proto

def IndexDefinitionToProto ( app_id , index_definition ) : proto = entity_pb . CompositeIndex ( ) proto . set_app_id ( app_id ) proto . set_id ( 0 ) proto . set_state ( entity_pb . CompositeIndex . WRITE_ONLY ) definition_proto = proto . mutable_definition ( ) definition_proto . set_entity_type ( index_definition . kind ) definition_proto . set_ancestor ( index_definition . ancestor ) if ( index_definition . properties is not None ) : is_geo = any ( ( ( x . mode == 'geospatial' ) for x in index_definition . properties ) ) for prop in index_definition . properties : prop_proto = definition_proto . add_property ( ) prop_proto . set_name ( prop . name ) if ( prop . mode == 'geospatial' ) : prop_proto . set_mode ( entity_pb . Index_Property . GEOSPATIAL ) elif is_geo : pass elif prop . IsAscending ( ) : prop_proto . set_direction ( entity_pb . Index_Property . ASCENDING ) else : prop_proto . set_direction ( entity_pb . Index_Property . DESCENDING ) return proto
transform individual index definition to protocol buffer .