{"swagger":"2.0","info":{"description":"API document for 3CF video analysis component","version":"1.0.0","title":"3CF Video Analysis Component","contact":{"email":"xuefeng.liu@honeywell.com"}},"host":"47.92.83.188:5000","basePath":"/","tags":[{"name":"factory","description":"all about factories"},{"name":"worker","description":"all about workers"},{"name":"equipment","description":"all about equipments"},{"name":"workstation","description":"all about workstations"},{"name":"face","description":"all about faces"},{"name":"camera","description":"all about cameras"},{"name":"task","description":"all about tasks"},{"name":"equipment model","description":"all about models for verify equipment existence"}],"schemes":["http"],"paths":{"/factory":{"get":{"tags":["factory"],"summary":"get a list of factories","produces":["application/json"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/Factory"}}}}},"post":{"tags":["factory"],"summary":"add a factory","produces":["text/html"],"parameters":[{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"factoryId":{"type":"integer"},"name":{"type":"string"},"description":{"type":"string"}}}}],"responses":{"200":{"description":"OK"},"400":{"description":"request parameter missing"}}}},"/factory/{factoryId}":{"get":{"tags":["factory"],"summary":"get a factory by id","produces":["application/json"],"parameters":[{"name":"factoryId","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Factory"}},"404":{"description":"resource not found"}}}},"/factory/{factoryId}/worker":{"get":{"tags":["worker"],"summary":"get worker list with factoryId and worker name","produces":["application/json"],"parameters":[{"name":"factoryId","in":"path","required":true},{"name":"name","in":"query","type":"string"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/Worker"}}},"400":{"description":"need to provide worker name"}}},"post":{"tags":["worker"],"summary":"add a worker to a factory","produces":["text/html"],"parameters":[{"name":"factoryId","in":"path","required":true},{"name":"body","in":"body","required":true,"schema":{"$ref":"#/definitions/Worker"}}],"responses":{"200":{"description":"OK"},"400":{"description":"request body missing parameters"}}}},"/factory/{factoryId}/worker/{workerEid}":{"get":{"tags":["worker"],"summary":"get a worker by factoryId and eid","produces":["application/json"],"parameters":[{"name":"factoryId","type":"integer","in":"path"},{"name":"workerEid","type":"string","in":"path"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Worker"}}}}},"/factory/{factory_id}/workstation":{"get":{"tags":["workstation"],"summary":"get a list of workstation","produces":["application/json"],"parameters":[{"name":"factory_id","type":"integer","required":true},{"name":"nameContain","type":"string","required":false}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/WorkerStation"}}}}},"post":{"tags":["workstation"],"summary":"add a workstation to a factory","produces":["text/html"],"parameters":[{"name":"body","in":"body","schema":{"type":"object","properties":{"workstationId":{"type":"integer"},"name":{"type":"string"},"description":{"type":"string"}}}},{"name":"factory_id","in":"path","type":"integer","required":true}],"responses":{"200":{"description":"OK"}}}},"/factory/{factory_id}/workstation/{workstation_id}":{"get":{"tags":["workstation"],"summary":"get workstation by id","produces":["application/json"],"parameters":[{"name":"factory_id","type":"integer","required":true,"in":"path"},{"name":"workstation_id","type":"integer","required":true,"in":"path"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/WorkerStation"}}}}},"/workstation/{workstation_id}/worker":{"get":{"tags":["workstation"],"summary":"get worker list of a workstation","produces":["application/json"],"parameters":[{"name":"workstation_id","type":"integer","required":true,"in":"path"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"eid":{"type":"string"},"name":{"type":"string"},"faceEncoding":{"type":"array","items":{"type":"number"},"maxLength":128,"minLength":128}}}}},"404":{"description":"factory or workstation not found"}}}},"/factory/{factory_id}/workstation/{workstation_id}/worker":{"post":{"tags":["workstation"],"summary":"add a worker to a station","produces":["text/html"],"parameters":[{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"eid":{"type":"string"}}}},{"name":"factory_id","in":"path","required":true,"type":"integer"},{"name":"workstation_id","in":"path","type":"integer","required":true}],"responses":{"200":{"description":"OK"},"400":{"description":"worker eid missing"}}}},"/factory/{factory_id}/worker/{eid}/face":{"get":{"tags":["face"],"summary":"get faces of a worker","produces":["application/json"],"parameters":[{"name":"factory_id","type":"integer","required":true,"in":"path"},{"name":"eid","type":"string","required":true,"in":"path"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"$ref":"#/definitions/Face"}}},"404":{"description":"worker not found"}}},"post":{"tags":["face"],"summary":"add a face","consumes":["multipart/form-data"],"produces":["text/html"],"parameters":[{"name":"factory_id","type":"integer","required":true,"in":"path"},{"name":"eid","type":"string","required":true,"in":"path"},{"name":"file","type":"file","in":"formData","description":"an image of the face to upload"}],"responses":{"200":{"description":"OK"},"400":{"description":"face encoding failed"}}}},"/face/{face_id}/img":{"get":{"tags":["face"],"summary":"get face image","parameters":[{"name":"face_id","type":"integer","required":true,"in":"path"}],"produces":["image/jpeg"],"responses":{"200":{"description":"OK"}}}},"/camera":{"post":{"tags":["camera"],"summary":"add camera","parameters":[{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"cameraId":{"type":"string"},"uri":{"type":"string"}}}}],"produces":["text/html"],"responses":{"201":"created"}}},"/camera/equipment_camera/equipment/{equipmentId}":{"put":{"tags":["camera"],"summary":"set camera","description":"add and set the camera for chekcing equipment exsistence for an equipment","parameters":[{"name":"equipmentId","type":"integer","required":true,"in":"path"},{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"cameraId":{"type":"string"},"xmin":{"type":"number"},"xmax":{"type":"number"},"ymin":{"type":"number"},"ymax":{"type":"number"}}}}],"produces":["text/html"],"responses":{"200":{"description":"OK"}}},"get":{"tags":["camera"],"summary":"get a camera","parameters":[{"name":"equipmentId","type":"integer","required":true,"in":"path"}],"produces":["application/json"],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/EquipmentCamera"}}}}},"/camera/equipment_active_camera/equipment/{equipmentId}":{"put":{"tags":["camera"],"summary":"set camera","description":"add and set the camera for chekcing equipment activity for an equipment","parameters":[{"name":"equipmentId","type":"integer","required":true,"in":"path"},{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"cameraId":{"type":"string"},"xmin":{"type":"number"},"xmax":{"type":"number"},"ymin":{"type":"number"},"ymax":{"type":"number"}}}}],"produces":["text/html"],"responses":{"200":{"description":"OK"}}}},"/camera/keyperson_camera/workstation/{workstationId}":{"put":{"tags":["camera"],"summary":"set a keyperson camera","description":"set the keyperson camera for a workstation","parameters":[{"name":"workstationId","type":"integer","required":true,"in":"path"},{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"cameraId":{"type":"string"}}}}],"responses":{"200":{"description":"OK"}}},"get":{"tags":["camera"],"summary":"get keyperson camera","description":"get the keyperson camera for a workstation","parameters":[{"name":"workstationId","type":"integer","required":true,"in":"path"}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/WorkstationCamera"}},"404":{"description":"no such camera"}}}},"/factory/{factory_id}/equipment":{"post":{"tags":["equipment"],"summary":"add a equipment","description":"add an equipment to a factory","parameters":[{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"equipmentId":{"type":"integer"},"description":{"type":"string"}}}},{"name":"factory_id","in":"path","required":true}],"produces":["text/html"],"responses":{"200":{"description":"OK"},"400":{"description":"equipemnt id not provided"},"404":{"description":"factory not found"},"500":{"description":"write to database failed"}}}},"/factory/{factory_id}/workstation/{workstation_id}/equipment":{"post":{"tags":["equipment"],"summary":"add an equipment","description":"If the equipemt id exists, add the equipmen to the workstation else, create the equipment record and add it to the factory and workstation.","parameters":[{"name":"factory_id","type":"integer","required":true,"in":"path"},{"name":"workstation_id","type":"integer","required":true,"in":"path"},{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"equipmentId":{"type":"integer"}}}}],"produces":["text/html"],"responses":{"200":{"description":"OK"},"400":{"description":"equipment not belong to this factory"},"404":{"description":"factory or workstation not found"},"500":{"description":"database write error"}}}},"/task/equipment/equipment/{equipmentId}":{"post":{"tags":["task"],"summary":"trigger a task","description":"trigger a task to check whether an equipment is still there","parameters":[{"name":"equipmentId","type":"integer","required":true,"in":"path"},{"name":"body","in":"body","schema":{"type":"object","properties":{"deadline":{"type":"string","format":"date-time","example":"2018-03-30T12:20:21"}}}}],"produces":["application/json"],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Task"}},"400":{"description":"argument missing or in wrong format"},"404":{"description":"equipment not found"},"500":{"description":"database or message queue error"}}}},"/task/equipment_active/equipment/{equipmentId}":{"post":{"tags":["task"],"summary":"trigger a task","description":"trigger a task to check whether an equipment is active","parameters":[{"name":"equipmentId","type":"integer","required":true,"in":"path"},{"name":"body","in":"body","schema":{"type":"object","properties":{"deadline":{"type":"string","format":"date-time","example":"2018-03-30T12:20:21","description":"deadline for the task, if the task starts later than this time, it fails"}}}}],"produces":["application/json"],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Task"}},"400":{"description":"argument missing or in wrong format"},"404":{"description":"equipment not found"},"500":{"description":"database or message queue error"}}}},"/task/keyperson/workstation/{workstationId}":{"post":{"tags":["task"],"summary":"trigger a task","description":"trigger a key person check task","parameters":[{"name":"workstationId","type":"integer","required":true,"in":"path"},{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"deadline":{"type":"string","format":"date-time","example":"2018-03-30T12:20:21"},"duration":{"type":"integer","description":"how long this task should run for, in seconds"}}}}],"produces":["application/json"],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Task"}},"400":{"description":"argument missing or in wrong format"},"404":{"description":"equipment not found"},"500":{"description":"database or message queue error"}}}},"/task/{taskId}":{"get":{"tags":["task"],"summary":"get a task status","parameters":[{"name":"taskId","type":"integer","required":true,"in":"path"}],"produces":["application/json"],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Task"}}}},"put":{"tags":["task"],"summary":"set a task status","parameters":[{"name":"body","in":"body","required":true,"schema":{"type":"object","properties":{"startTime":{"type":"string","format":"date-time","example":"2018-03-30T12:20:21"},"endTime":{"type":"string","format":"date-time","example":"2018-03-30T12:20:21"},"status":{"type":"string","enum":["created","ongoing","success","failed"]},"result":{"type":"string"}}}},{"name":"taskId","type":"integer","required":true,"in":"path"}],"produces":["text/html"],"responses":{"200":{"description":"OK"}}}},"/equipment/{equipmentId}/equipment_model/pb":{"get":{"tags":["equipment model"],"summary":"get model file","parameters":[{"name":"equipmentId","type":"integer","required":true,"in":"path"}],"produces":["application/octet-stream"],"responses":{"200":{"description":"OK"}}}},"/equipment/{equipmentId}/equipment_model":{"put":{"tags":["equipment model"],"summary":"set model","description":"set ML model for an equipment","parameters":[{"name":"equipmentId","type":"integer","required":true,"in":"path"},{"name":"file","type":"file","in":"formData","description":"model file to upload"}],"consumes":["multipart/form-data"],"produces":["text/html"],"responses":{"200":{"description":"OK"}}}}},"definitions":{"Factory":{"type":"object","properties":{"id":{"type":"number","example":1},"name":{"type":"string","example":"圣赛尔"},"description":{"type":"string"}}},"Worker":{"type":"object","properties":{"eid":{"type":"string","example":"H232559"},"name":{"type":"string","example":"刘雪峰"}}},"WorkerStation":{"type":"object","properties":{"id":{"type":"integer","example":1},"name":{"type":"string"},"factoryId":{"type":"integer"},"workers":{"type":"array","items":{"$ref":"#/definitions/Worker"}}}},"Face":{"type":"object","properties":{"id":{"type":"integer"},"eid":{"type":"string"},"factoryId":{"type":"integer"},"encoding":{"type":"array","items":{"type":"number"}}}},"EquipmentCamera":{"type":"object","properties":{"id":{"type":"string"},"uri":{"type":"string"},"xmin":{"type":"number"},"xmax":{"type":"number"},"ymin":{"type":"number"},"ymax":{"type":"number"},"equipmentId":{"type":"integer"}}},"EquipmentActiveCamera":{"type":"object","properties":{"id":{"type":"string"},"uri":{"type":"string"},"xmin":{"type":"number"},"xmax":{"type":"number"},"ymin":{"type":"number"},"ymax":{"type":"number"},"equipmentId":{"type":"integer"}}},"WorkstationCamera":{"type":"object","properties":{"id":{"type":"string"},"uri":{"type":"string"}}},"Task":{"type":"object","properties":{"id":{"type":"integer"},"type":{"type":"string","enum":["keyperson","equipment","equipment_active"]},"createTime":{"type":"string","format":"date-time","example":"2018-03-29T18:20:01"},"context":{"type":"string","description":"a json string as the task queue payload"},"status":{"type":"string","enum":["created","ongoing","success","fail"]},"result":{"type":"string","description":"a json string as the result"},"startTime":{"type":"string","format":"date-time","example":"2018-03-29T19:24:21"},"endTime":{"type":"string","format":"date-time","example":"2018-03-29T19:25:30"}}},"EquipmentModel":{"type":"object","properties":{"id":{"type":"integer"},"factoryId":{"type":"integer"},"mapping":{"type":"string"},"md5":{"type":"string"}}}}}