def put(self, ): print "Update operation of resource: Ac" json_struct = request.get_json() #json parser. try: existing_object = HvacAcImpl.get() except KeyError as inst: if inst.args[0] != '': return NotFoundError(inst.args[0] + " not found") new_object = create_instance(Ac, json_struct) if isinstance(new_object, BadRequestError): return new_object elif isinstance(new_object, NotFoundError): return new_object else: try: HvacAcImpl.put(new_object) js=new_object.json_serializer() except KeyError as inst: return NotFoundError(inst.args[0] + " not found") else: existing_object = modify_instance(existing_object, json_struct) if isinstance(existing_object, BadRequestError): return existing_object elif isinstance(existing_object, NotFoundError): return existing_object else: try: HvacAcImpl.put(existing_object) js=existing_object.json_serializer() except KeyError as inst: return NotFoundError(inst.args[0] + " not found") return Successful("Successful operation",json_dumps(js))
def get(self, ): print "Retrieve operation of resource: Ac" try: response = HvacAcImpl.get() except KeyError as inst: return NotFoundError(inst.args[0] + " not found") else: js = response.json_serializer() return Successful("Successful operation",json_dumps(js))
def post(self, ): print "Create operation of resource: Ac" try: response = HvacAcImpl.get() except KeyError as inst: if inst.args[0] != '': return NotFoundError(inst.args[0] + " not found") json_struct = request.get_json() #json parser. new_object = create_instance(Ac, json_struct) if isinstance(new_object, BadRequestError): return new_object elif isinstance(new_object, NotFoundError): return new_object else: try: HvacAcImpl.post(new_object) js=new_object.json_serializer() except KeyError as inst: return NotFoundError(inst.args[0] + " not found") else: return BadRequestError("Object already exists. For updates use PUT.") return Successful("Successful operation",json_dumps(js))