diff --git a/annofabapi/__version__.py b/annofabapi/__version__.py index 2d93b0cd..978180b4 100644 --- a/annofabapi/__version__.py +++ b/annofabapi/__version__.py @@ -1 +1 @@ -__version__ = "0.37.0" +__version__ = "0.38.0" diff --git a/annofabapi/wrapper.py b/annofabapi/wrapper.py index 4117728d..bd03ff4c 100644 --- a/annofabapi/wrapper.py +++ b/annofabapi/wrapper.py @@ -10,6 +10,8 @@ from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional +import requests + from annofabapi import AnnofabApi from annofabapi.exceptions import AnnofabApiException from annofabapi.models import ( @@ -623,19 +625,17 @@ def put_input_data_from_file( ######################################### # Public Method : Statistics ######################################### - def get_worktime_statistics(self, project_id: str) -> List[Any]: + def _request_location_header_url(self, response: requests.Response) -> Any: """ - タスク作業時間集計取得. - Location Headerに記載されたURLのレスポンスをJSON形式で返す。 + Location headerに記載されているURLの中身を返す。 Args: - project_id: プロジェクトID + response: Returns: - タスク作業時間集計 + Location headerに記載されているURLの中身 """ - _, response = self.api.get_worktime_statistics(project_id) url = response.headers["Location"] response = self.api.session.get(url) @@ -646,6 +646,87 @@ def get_worktime_statistics(self, project_id: str) -> List[Any]: content = self.api._response_to_content(response) return content + def get_task_statistics(self, project_id: str) -> List[Any]: + """ + getTaskStatistics APIのLocation headerの中身を返す。 + + Args: + project_id: プロジェクトID + + Returns: + + + """ + _, response = self.api.get_task_statistics(project_id) + return self._request_location_header_url(response) + + def get_account_statistics(self, project_id: str) -> List[Any]: + """ + getAccountStatistics APIのLocation headerの中身を返す。 + + Args: + project_id: + + Returns: + + """ + _, response = self.api.get_account_statistics(project_id) + return self._request_location_header_url(response) + + def get_inspection_statistics(self, project_id: str) -> List[Any]: + """ + getInspectionStatistics APIのLocation headerの中身を返す。 + + Args: + project_id: + + Returns: + + """ + _, response = self.api.get_inspection_statistics(project_id) + return self._request_location_header_url(response) + + def get_task_phase_statistics(self, project_id: str) -> List[Any]: + """ + getTaskPhaseStatistics APIのLocation headerの中身を返す。 + + Args: + project_id: + + Returns: + + """ + _, response = self.api.get_task_phase_statistics(project_id) + return self._request_location_header_url(response) + + def get_label_statistics(self, project_id: str) -> List[Any]: + """ + getLabelStatistics APIのLocation headerの中身を返す。 + + Args: + project_id: + + Returns: + + """ + _, response = self.api.get_label_statistics(project_id) + return self._request_location_header_url(response) + + def get_worktime_statistics(self, project_id: str) -> List[Any]: + """ + タスク作業時間集計取得. + Location Headerに記載されたURLのレスポンスをJSON形式で返す。 + + Args: + project_id: プロジェクトID + + Returns: + タスク作業時間集計 + + """ + _, response = self.api.get_worktime_statistics(project_id) + return self._request_location_header_url(response) + ######################################### # Public Method : Supplementary ######################################### diff --git a/generate/swagger/swagger.v2.yaml b/generate/swagger/swagger.v2.yaml index 0fd563f3..ffeeacb6 100644 --- a/generate/swagger/swagger.v2.yaml +++ b/generate/swagger/swagger.v2.yaml @@ -115,7 +115,7 @@ info: 上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。 - version: 0.91.0 + version: 0.93.0 title: AnnoFab Web API x-logo: url: "https://annofab.com/images/logo_landscape.png" @@ -387,6 +387,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -429,6 +435,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -471,6 +483,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -513,6 +531,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -555,6 +579,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -598,6 +628,11 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + schema: + type: string content: application/json: schema: diff --git a/generate/swagger/swagger.yaml b/generate/swagger/swagger.yaml index fd36a92f..80a2da54 100644 --- a/generate/swagger/swagger.yaml +++ b/generate/swagger/swagger.yaml @@ -116,7 +116,7 @@ info: 上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。 また、AggregationResultの集約の件数は、合計で10000件以下に制限されており、それを超える件数がある場合は上位10000件が取得されます。もし、省略された部分を取得したい場合は、検索条件を縛って結果に上る集約の数を減らしてください。 - version: 0.91.0 + version: 0.93.0 title: AnnoFab Web API x-logo: url: "https://annofab.com/images/logo_landscape.png" @@ -2394,6 +2394,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -2429,6 +2435,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -2461,6 +2473,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -2494,6 +2512,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: @@ -2528,6 +2552,12 @@ paths: responses: "200": description: 正常 + headers: + Location: + description: 認証済み一時URL + required: true + schema: + type: string content: application/json: schema: diff --git a/pyproject.toml b/pyproject.toml index a7f3ac8e..b0ec7d62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "annofabapi" -version = "0.37.0" +version = "0.38.0" description = "Python Clinet Library of AnnoFab WebAPI (https://annofab.com/docs/api/)" authors = ["yuji38kwmt "] maintainers = ["yuji38kwmt "] diff --git a/tests/test_api.py b/tests/test_api.py index 677372b0..c2d27f32 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -299,23 +299,29 @@ def test_wrapper_copy_project_member(self): class TestStatistics: - def test_statistics(self): - assert type(api.get_task_statistics(project_id)[0]) == list + def test_wrapper_statistics(self): + actual = wrapper.get_task_statistics(project_id) + assert type(actual) == list - def test_get_account_statistics(self): - assert type(api.get_account_statistics(project_id)[0]) == list + def test_wrapper_get_account_statistics(self): + actual = wrapper.get_account_statistics(project_id) + assert type(actual) == list - def test_get_inspection_statistics(self): - assert type(api.get_inspection_statistics(project_id)[0]) == list + def test_wrapper_get_inspection_statistics(self): + actual = wrapper.get_inspection_statistics(project_id) + assert type(actual) == list - def test_get_task_phase_statistics(self): - assert type(api.get_task_phase_statistics(project_id)[0]) == list + def test_wrapper_get_task_phase_statistics(self): + actual = wrapper.get_task_phase_statistics(project_id) + assert type(actual) == list - def test_get_label_statistics(self): - assert type(api.get_label_statistics(project_id)[0]) == list + def test_wrapper_get_label_statistics(self): + actual = wrapper.get_label_statistics(project_id) + assert type(actual) == list def test_wrapper_get_worktime_statistics(self): - assert type(wrapper.get_worktime_statistics(project_id)) == list + actual = wrapper.get_worktime_statistics(project_id) + assert type(actual) == list def test_graph_marker(self): print("get_markers") diff --git a/tests/test_dataclass.py b/tests/test_dataclass.py index db2d0171..04532905 100644 --- a/tests/test_dataclass.py +++ b/tests/test_dataclass.py @@ -162,27 +162,27 @@ def test_project_member(self): class TestStatistics: def test_statistics_get_task_statistics(self): - stat_list, _ = service.api.get_task_statistics(project_id) + stat_list = service.wrapper.get_task_statistics(project_id) stat = ProjectTaskStatisticsHistory.from_dict(stat_list[0]) assert type(stat) == ProjectTaskStatisticsHistory def test_statistics_get_account_statistics(self): - stat_list, _ = service.api.get_account_statistics(project_id) + stat_list = service.wrapper.get_account_statistics(project_id) stat = ProjectAccountStatistics.from_dict(stat_list[0]) assert type(stat) == ProjectAccountStatistics def test_statistics_get_inspection_statistics(self): - stat_list, _ = service.api.get_inspection_statistics(project_id) + stat_list = service.wrapper.get_inspection_statistics(project_id) stat = InspectionStatistics.from_dict(stat_list[0]) assert type(stat) == InspectionStatistics def test_statistics_get_task_phase_statistics(self): - stat_list, _ = service.api.get_task_phase_statistics(project_id) + stat_list = service.wrapper.get_task_phase_statistics(project_id) stat = TaskPhaseStatistics.from_dict(stat_list[0]) assert type(stat) == TaskPhaseStatistics def test_statistics_get_label_statistics(self): - stat_list, _ = service.api.get_label_statistics(project_id) + stat_list = service.wrapper.get_label_statistics(project_id) stat = LabelStatistics.from_dict(stat_list[0]) assert type(stat) == LabelStatistics