示例#1
0
def robots_robot_id_delete(robotId) -> str:
    try:
        robot = Robot.get(robotId)
        robot.delete()
    except Exception as e:      
        return 'Robot with id=%s does not exist.' % (robotId)
    return 'Successfully deleted robot with id=%s.' % (robotId)
def robots_robot_id_get(robotId):
    """ method to get a robot using robot id """
    try:
        robot = Robot.get(robotId)
    except Exception:
        return 'Robot with id=%s does not exist.' % (robotId),404
    return robot.attribute_values,200
def robots_robot_id_put(robotId, newRobot):
    """ method to update a robot using robot id """
    try:
        robot = Robot.get(robotId)
    except Exception:
        return 'Robot with id=%s does not exist.' % (robotId),404
	
	# Need to check that if building ID is changed, the new Building exists
    if 'buildingId' in newRobot:
    	try:
    		building = Building.get(newRobot['buildingId'])
    	except Exception as e:
    		return 'Building with specified ID does not exist',412
    
    # Do the same for sensor ID
    if 'sensorId' in newRobot:
        for val in newRobot['sensorId']:
     	    try:
     		    #print(val)
     		    sensor = Sensor.get(val)
     	    except Exception as e:
     		    return 'Sensor with specified ID does not exist',412

    attributes = robot.attribute_values.keys()
    for key in newRobot.keys():
        if key in attributes and key!= "id":
            # print(key)
            robot.update_item(key, value=newRobot[key], action='PUT')
    return 'Robot with id=%s updated successfully.' % (robotId),200
示例#4
0
def robots_robot_id_put(robotId, newRobot):
    """ method to update a robot using robot id """
    try:
        robot = Robot.get(robotId)
    except Exception:
        return 'Robot with id=%s does not exist.' % (robotId)

# Need to check that if building ID is changed, the new Building exists
    if 'buildingId' in newRobot:
        try:
            building = Building.get(newRobot['buildingId'])
        except Exception as e:
            return 'Building with specified ID does not exist'

    # Do the same for sensor ID
    if 'sensorId' in newRobot:
        try:
            sensor = Sensor.get(newRobot['sensorId'])
        except Exception as e:
            return 'Sensor with specified ID does not exist'

    attributes = robot.attribute_values.keys()
    for key in newRobot.keys():
        if key in attributes and key is not 'id':
            robot.update_item(key, value=newRobot[key], action='PUT')
    return 'Robot with id=%s updated successfully.' % (robotId)
示例#5
0
def robots_robot_id_get(robotId):
    """ method to get a robot using robot id """
    try:
        robot = Robot.get(robotId)
    except Exception:
        return 'Robot with id=%s does not exist.' % (robotId)
    return robot.attribute_values
示例#6
0
def robots_robot_id_delete(robotId) -> str:
    try:
        robot = Robot.get(robotId)
        robot.delete()
    except Exception as e:
        return 'Robot with id=%s does not exist.' % (robotId)
    return 'Successfully deleted robot with id=%s.' % (robotId)
def robots_robot_id_delete(robotId):
    """ method to delete a robot using robot id """
    try:
        robot = Robot.get(robotId)
        robot.delete()
    except Exception:      
        return 'Robot with id=%s does not exist.' % (robotId),404
    return 'Successfully deleted robot with id=%s.' % (robotId),200
示例#8
0
def robots_robot_id_delete(robotId):
    """ method to delete a robot using robot id """
    try:
        robot = Robot.get(robotId)
        robot.delete()
    except Exception:
        return 'Robot with id=%s does not exist.' % (robotId)
    return 'Successfully deleted robot with id=%s.' % (robotId)
示例#9
0
def robots_robot_id_put(robotId, newRobot) -> str:
    try:
        robot = Robot.get(robotId)
    except Exception as e:
        return 'Robot with id=%s does not exist.' % (robotId)
    attributes = robot.attribute_values.keys()
    for key in newRobot.keys():
        if key in attributes and key is not 'id':
            robot.update_item(key, value=newRobot[key], action='PUT')
    return 'Robot with id=%s updated successfully.' % (robotId)
示例#10
0
def robots_robot_id_put(robotId, newRobot) -> str:
    try:
        robot = Robot.get(robotId)
    except Exception as e:
        return 'Robot with id=%s does not exist.' % (robotId)
    attributes = robot.attribute_values.keys()
    for key in newRobot.keys():
        if key in attributes and key is not 'id':
            robot.update_item(key, value=newRobot[key], action='PUT')
    return 'Robot with id=%s updated successfully.' % (robotId)
示例#11
0
def robots_robot_id_get(robotId) -> str:
    try:
        robot = Robot.get(robotId)
    except Exception as e:
        return 'Robot with id=%s does not exist.' % (robotId)
    return robot.attribute_values
示例#12
0
def robots_robot_id_get(robotId) -> str:
    try:
        robot = Robot.get(robotId)
    except Exception as e:
        return 'Robot with id=%s does not exist.' % (robotId)
    return robot.attribute_values