def delete_object_type(id: str) -> RespT: """Deletes object type. --- delete: tags: - ObjectType summary: Deletes object type. parameters: - name: id in: path description: unique ID required: true schema: type: string responses: 200: description: Ok 404: description: ObjectType not found. content: application/json: schema: $ref: WebApiError """ try: del OBJECT_TYPES[id] except KeyError: return common.WebApiError(f"ObjectType {id} was not found.", PROJECT_SERVICE_NAME).to_json(), 404 return Response(status=200)
def delete_collision(collisionId: str) -> RespT: """Deletes collision object. --- delete: tags: - Collisions summary: Deletes collision object. parameters: - name: collisionId in: path description: unique ID required: true schema: type: string responses: 200: description: Ok 404: description: Model not found. content: application/json: schema: type: string """ try: del collision_objects[collisionId] except KeyError: return jsonify("Not found"), 404 return Response(status=200)
def delete_file(fileId: str) -> RespT: """Deletes file. --- delete: tags: - Files summary: Deletes file. parameters: - name: fileId in: path description: unique ID required: true schema: type: string responses: 200: description: Ok 404: description: File not found. content: application/json: schema: type: string """ try: del FILES[fileId] except KeyError: return jsonify("Not found"), 404 return Response(status=200)
def put_start() -> RespT: """Starts the system. --- put: tags: - System description: Starts the system. responses: 200: description: Ok """ global started delay() started = True return Response(status=200)
def put_stop() -> RespT: """Stops the system. --- put: tags: - System description: Stops the system. responses: 200: description: Ok """ global started if started: delay() started = False collision_objects.clear() return Response(status=200)
def delete_model(id: str) -> RespT: """Deletes model. --- delete: tags: - Models summary: Deletes model. parameters: - name: id in: path description: unique ID required: true schema: type: string responses: 200: description: Ok 404: description: Not found. content: application/json: schema: $ref: WebApiError """ try: del BOXES[id] except KeyError: try: del CYLINDERS[id] except KeyError: try: del SPHERES[id] except KeyError: try: del MESHES[id] except KeyError: return common.WebApiError( f"Model {id} was not found.", PROJECT_SERVICE_NAME).to_json(), 404 return Response(status=200)
def put_file(fileId: str) -> RespT: """Puts file. --- put: description: Puts file. tags: - Files parameters: - name: fileId in: path description: unique ID required: true schema: type: string requestBody: content: multipart/form-data: schema: type: object required: - file properties: file: type: string format: binary responses: 200: description: Ok 400: description: Invalid file id provided. content: application/json: schema: type: string """ buff = BytesIO() fs = request.files["file"] fs.save(buff) FILES[fileId] = buff, fs.filename return Response(status=200)
def put_mesh() -> RespT: """Add or update mesh. --- put: tags: - Models description: Add or update mesh. requestBody: content: application/json: schema: $ref: Mesh responses: 200: description: Ok """ if not isinstance(request.json, dict): raise FlaskException("Body should be a JSON dict containing Mesh.", error_code=400) mesh = object_type.Mesh.from_dict(humps.decamelize(request.json)) MESHES[mesh.id] = mesh return Response(status=200)
def put_sphere() -> RespT: """Add or update sphere. --- put: tags: - Models description: Add or update sphere. requestBody: content: application/json: schema: $ref: Sphere responses: 200: description: Ok """ if not isinstance(request.json, dict): raise FlaskException("Body should be a JSON dict containing Sphere.", error_code=400) sphere = object_type.Sphere.from_dict(humps.decamelize(request.json)) SPHERES[sphere.id] = sphere return Response(status=200)
def put_cylinder() -> RespT: """Add or update cylinder. --- put: tags: - Models description: Add or update service type. requestBody: content: application/json: schema: $ref: Cylinder responses: 200: description: Ok """ if not isinstance(request.json, dict): raise FlaskException("Body should be a JSON dict containing Cylinder.", error_code=400) cylinder = object_type.Cylinder.from_dict(humps.decamelize(request.json)) CYLINDERS[cylinder.id] = cylinder return Response(status=200)
def put_box() -> RespT: """Add or update box. --- put: tags: - Models description: Add or update service type. requestBody: content: application/json: schema: $ref: Box responses: 200: description: Ok """ if not isinstance(request.json, dict): raise FlaskException("Body should be a JSON dict containing Box.", error_code=400) box = object_type.Box.from_dict(humps.decamelize(request.json)) BOXES[box.id] = box return Response(status=200)