alignak_backend_client/backend_client.py
def main():
    """
    Main function
    """
    bc = BackendUpdate()
    bc.initialize()
    logger.info("backend_client, version: %s", __version__)
    logger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

    success = False
    if bc.item_type and bc.action == 'list':
        success = bc.get_resource_list(bc.item_type, bc.item)

    if bc.item_type and bc.action == 'get':
        if bc.list:
            success = bc.get_resource_list(bc.item_type, bc.item)
        else:
            if not bc.item:
                logger.error("Can not %s a %s with no name!", bc.action, bc.item_type)
                logger.error("Perharps you missed some parameters, run 'alignak-backend-cli -h'")
                exit(64)
            success = bc.get_resource(bc.item_type, bc.item)

    if bc.action in ['add', 'update']:
        success = bc.create_update_resource(bc.item_type, bc.item, bc.action == 'update')

    if bc.action == 'delete':
        success = bc.delete_resource(bc.item_type, bc.item)

    if not success:
        logger.error("%s '%s' %s failed", bc.item_type, bc.item, bc.action)
        if not bc.verbose:
            logger.warning("Set verbose mode to have more information (-v)")
        exit(2)

    exit(0)
def main():
    """
    Main function
    """
    bc = BackendUpdate()
    bc.initialize()
    logger.info("backend_client, version: %s", __version__)
    logger.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

    success = False
    if bc.item_type and bc.action == 'list':
        success = bc.get_resource_list(bc.item_type, bc.item)

    if bc.item_type and bc.action == 'get':
        if bc.list:
            success = bc.get_resource_list(bc.item_type, bc.item)
        else:
            if not bc.item:
                logger.error("Can not %s a %s with no name!", bc.action, bc.item_type)
                logger.error("Perharps you missed some parameters, run 'alignak-backend-cli -h'")
                exit(64)
            success = bc.get_resource(bc.item_type, bc.item)

    if bc.action in ['add', 'update']:
        success = bc.create_update_resource(bc.item_type, bc.item, bc.action == 'update')

    if bc.action == 'delete':
        success = bc.delete_resource(bc.item_type, bc.item)

    if not success:
        logger.error("%s '%s' %s failed", bc.item_type, bc.item, bc.action)
        if not bc.verbose:
            logger.warning("Set verbose mode to have more information (-v)")
        exit(2)

    exit(0)
Main function