Package: qronos-client
qronos-clientPython client for QRonosInstallationThis package can be installed via pip:pip install qronos-clientExample UsageAuthenticationfromqronosimportQRonosClient# Create client and loginqronos=QRonosClient(host='https://dev.qronos.xyz')token,expiry=qronos.login(username='Quentin',password='Rogers')# Alternatively, if you already have a tokenqronos=QRonosClient(host='https://dev.qronos.xyz',token='ABCDEFGHIJKLMN')# Logoutqronos.logout(all_tokens=True)Tracker (Item) Data Import# Import Tracker (Item) Datajob_id=qronos.tracker_import(tracker_id=24,unique_columns=["Part Number","Weight"],can_add_item=True,can_delete_item=False,data=[{"Part Number":"A1","Weight":5},{"Part Number":"A2","Weight":8}],)Stage Data Import# Import Stage Datajob_id=qronos.stage_import(stage_id=2,data=[{"Part Number":"A1","leadtime":5},{"Part Number":"A2","actual":"2020-10-26"}],)Stage Data Import by Tracker Stage# Import Stage Datajob_id=qronos.stage_import(tracker_stage_id=2,data=[{"Part Number":"A1","leadtime":5},{"Part Number":"A2","actual":"2020-10-26"}],)Import Status# Check Status of an Importstatus=qronos.import_status(job_id=job_id)Delete Items# Delete Itemsjob_id=qronos.delete_items(tracker_id=2,data=["A","B"],)Paginated servicesTheget_item_attributes,get_item_stages,get_item_stage_historyandget_all_item_attribute_historyservices return paginated responses in the form:{"next":"http://127.0.0.1:8000/api/attributes/?cursor=cD0x&page_size=1","previous":null,"items":[{},...]}Thenextandpreviousfields contain the API url for the next/previous pages respectively.
If there are no next or previous pages the value would benull.All items can be returned as a single list of items by theget_all_item_datamethod.Following are some usage examples for theget_item_attributesservice. Pagination works the same way for all the services. I.e. you can use the same example by just changing the name of the service.# Request the first page of datadata=qronos.get_item_attributes(tracker=3,page_size=2,)# Request the next page. This will use the same page_size as the previous request.data=qronos.get_item_attributes(tracker=3,page=data.get("next"))# Request the next next page. Use page_size to change the size of the page.data=qronos.get_item_attributes(tracker=3,page=data.get("next"),page_size=10,)# Request the previous pagedata=qronos.get_item_attributes(tracker=3,page=data.get("previous"))# Requesting all the pages using a while loopall_data=[]data=qronos.get_item_attributes(tracker=3,page_size=10)all_data.extend(data.get('items'))whilenextp:=data.get('next'):data=qronos.get_item_attributes(tracker=3,page=nextp)all_data.extend(data.get('items'))Get Item Attribute DataAt minimum you must request atrackeror aunique_key/unique_keysYou cannot request both aunique_keyandunique_keysUsepage_sizeto change the size of the paginated resultUsepageto navigate to next/previous page# Get Item Attribute Data by trackeritem_data=qronos.get_item_attributes(tracker=3,show_non_mastered=False,show_mastered=True,)# Get Item Attribute Data by unique keysitem_data=qronos.get_item_attributes(unique_keys=["800000689","800000726","800000727"],show_non_mastered=True,show_mastered=True,)# Get Item Attribute Data by single unique keyitem_data=qronos.get_item_attributes(unique_key="800000689",show_non_mastered=False,show_mastered=True,)# Get Item Attribute Data by single unique key for only a single trackeritem_data=qronos.get_item_attributes(unique_key="800000689",tracker=4,show_non_mastered=False,show_mastered=True,)Get Item Stage DataAt minimum you must request atrackeror aunique_key/unique_keysYou cannot request both aunique_keyandunique_keysYou cannot request both astageandstagesYou cannot request both atracker_stageandtracker_stagesYou cannot request a combinations ofstageandtracker_stagefieldsUsepage_sizeto change the size of the paginated resultUsepageto navigate to next/previous page# Get Item Stage Data for a trackerstage_data=qronos.get_item_stages(tracker=3)# Get Item Stage Data by unique keysstage_data=qronos.get_item_stages(unique_keys=["800000689","800000726","800000727"])# Get Item Stage Data by single unique key but only for a single stagestage_data=qronos.get_item_stages(unique_key="800000689",stage=54,)# Get Item Stage Data by single unique key but only for a single tracker stagestage_data=qronos.get_item_stages(unique_key="800000689",tracker_stage=12,)# Get Item Stage Data for a list of stages on a certain trackerstage_data=qronos.get_item_stages(tracker=4,stages=[54,55,56],)# Get Item Stage Data for a list of tracker stages on a certain trackerstage_data=qronos.get_item_stages(tracker=4,tracker_stages=[12,13,14],)Get Item Stage History DataGet the history of changes to ItemStages.
Request follow the same pattern as for Get Item Stage with the addition of the following options:#  Get changes between a start and end date on a particular trackerstage_history_data=qronos.get_item_stage_history(tracker=4,interval_start_date="2020-12-25",# using ISO-8601 format (YYYY-MM-DD)interval_end_date="2021-12-25",)# Get ItemStageHistory for the changes to the "actual" and "leadtime" fields of ItemStages on a particular trackerstage_history_data=qronos.get_item_stage_history(tracker=4,fields=["actual","leadtime"])Get All Data MethodsThese methods will loop through eachpageand aggregate the data into a single list of items.get_all_item_attributesget_all_item_stagesget_all_item_stage_historyget_all_item_attribute_history# Get all Item Attribute Data for a trackerattributes_data=qronos.get_all_item_attributes(tracker=3)# Get all Item Stage Data for a trackerstage__data=qronos.get_all_item_stages(tracker=3)# Get all Item Stage History Data for a trackerattribute_data=qronos.get_all_item_stage_history(tracker=3)# Get all Item Attribute History Data for a tracker & attributesattribute_history=qronos.get_all_item_attribute_history(tracker=4,attribute_names=["Attribute A","Attribute B"],page_size=500,)TestingPlease speak with a QRonos Demo Site Admin for credentials in order to run the tests.