def to_sensor_db_model(sensor_api_model=None):
 class_name = getattr(sensor_api_model, 'class_name', None)
 pack = getattr(sensor_api_model, 'pack', None)
 entry_point = get_sensor_entry_point(sensor_api_model)
 artifact_uri = getattr(sensor_api_model, 'artifact_uri', None)
 description = getattr(sensor_api_model, 'description', None)
 trigger_types = getattr(sensor_api_model, 'trigger_types', [])
 poll_interval = getattr(sensor_api_model, 'poll_interval', None)
 enabled = getattr(sensor_api_model, 'enabled', True)
 poll_interval = getattr(sensor_api_model, 'poll_interval', None)
 if (poll_interval and (poll_interval < MINIMUM_POLL_INTERVAL)):
  raise ValueError(('Minimum possible poll_interval is %s seconds' % MINIMUM_POLL_INTERVAL))
 for trigger_type in trigger_types:
  trigger_type['pack'] = pack
 trigger_type_refs = create_trigger_types(trigger_types)
 return _create_sensor_type(pack=pack, name=class_name, description=description, artifact_uri=artifact_uri, entry_point=entry_point, trigger_types=trigger_type_refs, poll_interval=poll_interval, enabled=enabled)

def to_sensor_db_model ( sensor_api_model = None ) : class_name = getattr ( sensor_api_model , 'class_name' , None ) pack = getattr ( sensor_api_model , 'pack' , None ) entry_point = get_sensor_entry_point ( sensor_api_model ) artifact_uri = getattr ( sensor_api_model , 'artifact_uri' , None ) description = getattr ( sensor_api_model , 'description' , None ) trigger_types = getattr ( sensor_api_model , 'trigger_types' , [ ] ) poll_interval = getattr ( sensor_api_model , 'poll_interval' , None ) enabled = getattr ( sensor_api_model , 'enabled' , True ) poll_interval = getattr ( sensor_api_model , 'poll_interval' , None ) if ( poll_interval and ( poll_interval < MINIMUM_POLL_INTERVAL ) ) : raise ValueError ( ( 'Minimum possible poll_interval is %s seconds' % MINIMUM_POLL_INTERVAL ) ) for trigger_type in trigger_types : trigger_type [ 'pack' ] = pack trigger_type_refs = create_trigger_types ( trigger_types ) return _create_sensor_type ( pack = pack , name = class_name , description = description , artifact_uri = artifact_uri , entry_point = entry_point , trigger_types = trigger_type_refs , poll_interval = poll_interval , enabled = enabled )
converts a sensortypeapi model to db model .