Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 33 additions & 32 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion annofabapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.28.1'
__version__ = '0.29.0'
9 changes: 6 additions & 3 deletions annofabapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import backoff
import requests
from requests.auth import AuthBase
from requests.cookies import RequestsCookieJar

import annofabapi.utils
from annofabapi.generated_api import AbstractAnnofabApi
Expand Down Expand Up @@ -87,7 +88,7 @@ def __init__(self, login_user_id: str, login_password: str, endpoint_url: str =
token_dict: Optional[Dict[str, Any]] = None

#: Signed Cookie情報
cookies: Optional[Dict[str, Any]] = None
cookies: Optional[RequestsCookieJar] = None

class __MyToken(AuthBase):
"""
Expand Down Expand Up @@ -248,14 +249,16 @@ def request(cookies):
return self.session.get(url, **kwargs)

if self.cookies is None:
self.cookies, _ = self._get_signed_cookie(project_id)
_, r = self._get_signed_cookie(project_id)
self.cookies = r.cookies

response = request(self.cookies)

# CloudFrontから403 Errorが発生したときは、別プロジェクトのcookieを渡している可能性があるので、
# Signed Cookieを発行して、再度リクエストを投げる
if response.status_code == requests.codes.forbidden and response.headers.get("server") == "CloudFront":
self.cookies, _ = self._get_signed_cookie(project_id)
_, r = self._get_signed_cookie(project_id)
self.cookies = r.cookies
response = request(self.cookies)

annofabapi.utils.log_error_response(logger, response)
Expand Down
5 changes: 3 additions & 2 deletions annofabapi/api2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Union # pylint: disable=unused-import

import requests
from requests.cookies import RequestsCookieJar

import annofabapi.utils
from annofabapi.api import AnnofabApi
Expand All @@ -26,7 +27,7 @@ def __init__(self, api: AnnofabApi):
self.url_prefix = f"{api.endpoint_url}/api/v2"

#: Signed Cookie情報
cookies: Optional[Dict[str, Any]] = None
cookies: Optional[RequestsCookieJar] = None

#########################################
# Private Method
Expand Down Expand Up @@ -111,5 +112,5 @@ def get_signed_access_v2(self, query_params: Dict[str, Any]) -> Tuple[Dict[str,

content, response = self._request_wrapper(http_method, url_path, **keyword_params)
# Signed Cookieをインスタンスに保持する
self.cookies = content
self.cookies = response.cookies
return content, response
22 changes: 11 additions & 11 deletions annofabapi/dataclass/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ class Inspection:
"""検査ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

phase: TaskPhase
""""""
"""検査コメントを付与したときのタスクフェーズ。[詳細はこちら](#section/TaskPhase)"""

phase_stage: Optional[int]
""""""
phase_stage: int
"""検査コメントを付与したときのフェーズのステージ"""

commenter_account_id: str
""""""
"""検査コメントを付与したユーザのアカウントID"""

annotation_id: Optional[str]
"""特定のアノテーションに対するコメントの場合はそのアノテーションのID、座標に対する場合は値なし。 [詳細はこちら](#section/AnnotationId)。 """
"""検査コメントに紐づくアノテーションのID。アノテーションに紐付けられていない場合(アノテーションの付け忘れに対する指定など)は未指定。 [詳細はこちら](#section/AnnotationId)。 """

data: OneOfInspectionDataPointInspectionDataPolylineInspectionDataTime
""""""
"""検査コメントの座標値や区間。 * `InspectionDataPoint`:点で検査コメントを付与したときの座標値 * `InspectionDataPolyline`:ポリラインで検査コメントを付与したときの座標値 * `InspectionDataTime`:検査コメントを付与した区間(動画プロジェクトの場合) """

parent_inspection_id: Optional[str]
"""検査ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
"""返信先の検査コメントの検査ID。返信先の検査コメントは「スレッド内の直前のコメント」ではなく「スレッドの先頭のコメント」を指します。 """

phrases: Optional[List[str]]
"""選択された定型指摘ID. 未選択時は空"""
"""参照している定型指摘のID。"""

comment: Optional[str]
""""""
comment: str
"""検査コメントの中身 """

status: InspectionStatus
""""""
Expand All @@ -68,4 +68,4 @@ class Inspection:
""""""

updated_datetime: Optional[str]
"""新規作成時は未指定、更新時は必須(更新前の日時) """
""""""
13 changes: 9 additions & 4 deletions annofabapi/generated_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def batch_update_inspections(self, project_id: str, task_id: str, input_data_id:
authorizations: AllProjectMember


検査コメントを一括更新します。 タスクの現在の担当者でない場合、409エラーになります。 リクエストボディは、1個以上の「操作」オブジェクトを含むJSON配列になります。 操作オブジェクトには、「更新(作成含む)」と「削除」の2通りがあり、それぞれJSONオブジェクト構造が異なります。 これら操作オブジェクトを複数含めることで、1リクエストで複数の更新や削除ができます。 既に作成済みの検査コメントのうち、リクエストボディの配列に含まれないものは更新されません。 複数の操作のうち、1つでも失敗するとAPIのレスポンス全体としては失敗になります。 成功した部分までは反映されます。
検査コメントを一括更新します。 タスクの現在の担当者でない場合、またはタスクの状態が「作業中」でない場合は409エラーになります。 リクエストボディは、1個以上の「操作」オブジェクトを含むJSON配列になります。 操作オブジェクトには、「更新(作成含む)」と「削除」の2通りがあり、それぞれJSONオブジェクト構造が異なります。 これら操作オブジェクトを複数含めることで、1リクエストで複数の更新や削除ができます。 既に作成済みの検査コメントのうち、リクエストボディの配列に含まれないものは更新されません。 複数の操作のうち、1つでも失敗するとAPIのレスポンス全体としては失敗になります。 成功した部分までは反映されます。

Args:
project_id (str): プロジェクトID (required)
Expand Down Expand Up @@ -1732,7 +1732,8 @@ def post_project_inputs_update(self, project_id: str, **kwargs) -> Tuple[Any, re
keyword_params: Dict[str, Any] = {}
return self._request_wrapper(http_method, url_path, **keyword_params)

def post_project_tasks_update(self, project_id: str, **kwargs) -> Tuple[Any, requests.Response]:
def post_project_tasks_update(self, project_id: str, query_params: Optional[Dict[str, Any]] = None,
**kwargs) -> Tuple[Any, requests.Response]:
"""プロジェクトのタスク全件ファイル更新開始


Expand All @@ -1743,15 +1744,19 @@ def post_project_tasks_update(self, project_id: str, **kwargs) -> Tuple[Any, req

Args:
project_id (str): プロジェクトID (required)
query_params (Dict[str, Any]): Query Parameters
v (str): APIの戻り型のバージョンを指定します。 値と戻り型の対応は以下です。 - \"1\":Message - \"2\":PostProjectTasksUpdateResponse

Returns:
Tuple[Message, requests.Response]
Tuple[OneOfMessagePostProjectTasksUpdateResponse, requests.Response]


"""
url_path = f'/projects/{project_id}/rawdata/tasks'
http_method = 'POST'
keyword_params: Dict[str, Any] = {}
keyword_params: Dict[str, Any] = {
'query_params': query_params,
}
return self._request_wrapper(http_method, url_path, **keyword_params)

def put_project(self, project_id: str, request_body: Optional[Any] = None,
Expand Down
39 changes: 25 additions & 14 deletions annofabapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,27 +1920,27 @@ class InputDataType(Enum):
* inspection_id: str
検査ID。[値の制約についてはこちら。](#section/API-Convention/APIID)
* phase: TaskPhase

検査コメントを付与したときのタスクフェーズ。[詳細はこちら](#section/TaskPhase)
* phase_stage: int

検査コメントを付与したときのフェーズのステージ
* commenter_account_id: str

検査コメントを付与したユーザのアカウントID
* annotation_id: str
特定のアノテーションに対するコメントの場合はそのアノテーションのID、座標に対する場合は値なし。 [詳細はこちら](#section/AnnotationId)。
検査コメントに紐づくアノテーションのID。アノテーションに紐付けられていない場合(アノテーションの付け忘れに対する指定など)は未指定。 [詳細はこちら](#section/AnnotationId)。
* data: OneOfInspectionDataPointInspectionDataPolylineInspectionDataTime

検査コメントの座標値や区間。 * `InspectionDataPoint`:点で検査コメントを付与したときの座標値 * `InspectionDataPolyline`:ポリラインで検査コメントを付与したときの座標値 * `InspectionDataTime`:検査コメントを付与した区間(動画プロジェクトの場合)
* parent_inspection_id: str
検査ID。[値の制約についてはこちら。](#section/API-Convention/APIID)
返信先の検査コメントの検査ID。返信先の検査コメントは「スレッド内の直前のコメント」ではなく「スレッドの先頭のコメント」を指します。
* phrases: List[str]
選択された定型指摘ID. 未選択時は空
参照している定型指摘のID。
* comment: str

検査コメントの中身
* status: InspectionStatus

* created_datetime: str

* updated_datetime: str
新規作成時は未指定、更新時は必須(更新前の日時)


"""

Expand All @@ -1955,7 +1955,7 @@ class InputDataType(Enum):
* y: int

* type: str
[詳しくはこちら](#section/API-Convention/API-_type)
`Point` [詳しくはこちら](#section/API-Convention/API-_type)

"""

Expand All @@ -1968,7 +1968,7 @@ class InputDataType(Enum):
* coordinates: List[InspectionDataPolylineCoordinates]
ポリラインを構成する頂点の配列
* type: str
[詳しくはこちら](#section/API-Convention/API-_type)
`Polyline` [詳しくはこちら](#section/API-Convention/API-_type)

"""

Expand All @@ -1992,11 +1992,11 @@ class InputDataType(Enum):
Kyes of Dict

* start: float

開始時間(ミリ秒)。小数点以下はミリ秒以下を表します。
* end: float

終了時間(ミリ秒)。小数点以下はミリ秒以下を表します。
* type: str
[詳しくはこちら](#section/API-Convention/API-_type)
`Time` [詳しくはこちら](#section/API-Convention/API-_type)

"""

Expand Down Expand Up @@ -2717,6 +2717,17 @@ class OrganizationMemberStatus(Enum):
* job: JobInfo


"""

PostProjectTasksUpdateResponse = Dict[str, Any]
"""


Kyes of Dict

* job: JobInfo


"""


Expand Down
Loading