예제 #1
0
 def get_job_result(self, project_id: str, job_id: str) -> JobResult:
     assert project_id is not None
     assert job_id is not None
     url = urls.job_result.format(project_id, job_id)
     response = self.requester.get(url=url)
     response = JSON2Obj(JobResult(), json.dumps(response.data)).json2obj()
     return response
예제 #2
0
 def get_project_summary(self, project_id: str) -> ProjectSummary:
     assert project_id is not None
     url = urls.project_summary.format(project_id)
     response = self.requester.get(url=url)
     response = JSON2Obj(ProjectSummary(),
                         json.dumps(response.data)).json2obj()
     return response
예제 #3
0
 def get_batch_summary(self, batch_id: str,
                       project_id: str) -> BatchSummary:
     assert batch_id is not None
     assert project_id is not None
     url = urls.batch_summary.format(project_id, batch_id)
     response = self.requester.get(url=url)
     response = JSON2Obj(BatchSummary(),
                         json.dumps(response.data)).json2obj()
     return response
예제 #4
0
 def create_batch(self, name, label, description, project_id: str) -> Batch:
     assert name is not None
     assert label is not None
     assert description is not None
     assert project_id is not None
     url = urls.batch_creation.format(project_id)
     batch = Batch(name=name, label=label, description=description)
     response = self.requester.post(url=url, data=batch)
     batch_response = JSON2Obj(BatchResponse(), json.dumps(response.data)).json2obj()
     batch.id = batch_response.batch_id
     return batch
예제 #5
0
 def get_batch_summary(self, batch_id: str, project_id: str, next_page_token: str = None) -> BatchSummary:
     assert batch_id is not None
     assert project_id is not None
     if next_page_token is None:
         url = urls.batch_summary.format(project_id, batch_id)
     else:
         url = urls.batch_summary.format(project_id, batch_id) + "?page_token=" + next_page_token
     response = self.requester.get(
         url=url
     )
     response = JSON2Obj(BatchSummary(), json.dumps(response.data)).json2obj()
     return response
예제 #6
0
 def create_job(self, reference_id: str, tag: str, data: Data, project_id: str,
                priority_weight: int = 5, batch_id: str = None) -> Job:
     assert project_id is not None and type(project_id) is str
     assert issubclass(type(data), Data) is True
     if not data.valid():
         raise ExceptionCodes.FS_0003
     url = urls.job_creation.format(project_id)
     job = Job(reference_id=reference_id, tag=tag, data=data, priority_weight=priority_weight, batch_id=batch_id)
     response = self.requester.post(
         url=url,
         data=job
     )
     job_response = JSON2Obj(JobResponse(), json.dumps(response.data)).json2obj()
     job.id = job_response.job_id
     return job
예제 #7
0
 def test_json2obj(self):
     test_data = JSON2Obj(obj=URL(), data=json.dumps({"url":
                                                      "yo_2"})).json2obj()
     self.assertEqual(test_data.url, URL().url)