Skip to content

Commit 54e59a9

Browse files
authored
Merge pull request #611 from kurusugawa-computer/af-update
annofab update
2 parents 4a60876 + 37f4505 commit 54e59a9

File tree

9 files changed

+326
-40
lines changed

9 files changed

+326
-40
lines changed

annofabapi/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from annofabapi.api2 import AnnofabApi2
33
from annofabapi.wrapper import Wrapper
44
from annofabapi.resource import build, build_from_netrc, build_from_env, Resource
5+
from annofabapi.exceptions import NotSupportedUserError
56

67
from .__version__ import __version__
78

@@ -13,5 +14,6 @@
1314
"build_from_netrc",
1415
"build_from_env",
1516
"Resource",
17+
"NotSupportedUserError",
1618
"__version__",
1719
]

annofabapi/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from requests.auth import AuthBase
1212
from requests.cookies import RequestsCookieJar
1313

14-
from annofabapi.exceptions import NotLoggedInError
14+
from annofabapi.exceptions import NotLoggedInError, NotSupportedUserError
1515
from annofabapi.generated_api import AbstractAnnofabApi
1616

1717
logger = logging.getLogger(__name__)
@@ -637,6 +637,10 @@ def login(self) -> Tuple[Dict[str, Any], requests.Response]:
637637

638638
response = self._execute_http_request("post", url, json=login_info)
639639
json_obj = response.json()
640+
if "token" not in json_obj:
641+
raise NotSupportedUserError(
642+
f"ユーザー(ユーザーID: {self.login_user_id})はMFAが有効です。" "MFAが有効なユーザーは、annofab-api-python-clientを利用できません。"
643+
)
640644
self.token_dict = json_obj["token"]
641645

642646
logger.debug("Logged in successfully. user_id = %s", self.login_user_id)

annofabapi/exceptions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,12 @@ def __init__(self, message: str, uploaded_data_hash: str, response_etag: str):
6666
self.response_etag = response_etag
6767

6868
super().__init__(message)
69+
70+
71+
class NotSupportedUserError(Exception):
72+
"""
73+
annofab-api-python-clientでサポートされていないユーザが実行した際のエラー
74+
"""
75+
76+
def __init__(self, message: str):
77+
super().__init__(message)

annofabapi/generated_api.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,15 +1072,15 @@ def get_my_notification_messages(
10721072
authorizations: Everyone
10731073
10741074
1075-
自分に届いている通知メッセージを一括で取得します。 自身に届いている通知メッセージが上限(10000件)を超える場合、タイムスタンプが新しい順で上限を超える通知メッセージは取得できません。 また、上限を超える場合、開封済みの通知メッセージの数は、取得可能な通知メッセージ中の集計値となります。詳細はレスポンスの項目を参照ください。
1075+
自分に届いている通知メッセージを、メッセージの作成日時が新しい順で、一括取得します。 自身に届いている通知メッセージが上限(10000件)を超える場合、上限を超えた分の通知メッセージは取得できません。 また、上限を超える場合、開封済みの通知メッセージの数は、取得可能な通知メッセージ中の集計値となります。詳細はレスポンスの項目を参照ください。
10761076
10771077
Args:
10781078
query_params (Dict[str, Any]): Query Parameters
10791079
page (int): 表示するページ番号
10801080
limit (int): 1ページあたりの取得するデータ件数
10811081
10821082
Returns:
1083-
Tuple[GetMyMessagesResponse, requests.Response]
1083+
Tuple[MyNotificationList, requests.Response]
10841084
10851085
10861086
"""
@@ -1092,6 +1092,29 @@ def get_my_notification_messages(
10921092
keyword_params.update(**kwargs)
10931093
return self._request_wrapper(http_method, url_path, **keyword_params)
10941094

1095+
def get_my_notification_unread_messages_count(self, **kwargs) -> Tuple[Any, requests.Response]:
1096+
"""自分に届いている通知メッセージの未読件数を取得
1097+
https://annofab.com/docs/api/#operation/getMyNotificationUnreadMessagesCount
1098+
1099+
1100+
authorizations: Everyone
1101+
1102+
1103+
自分に届いている通知メッセージの未読件数を取得します。
1104+
1105+
Args:
1106+
1107+
Returns:
1108+
Tuple[MyNotificationUnreadMessagesCount, requests.Response]
1109+
1110+
1111+
"""
1112+
url_path = f"/my/unread-messages-count"
1113+
http_method = "GET"
1114+
keyword_params: Dict[str, Any] = {}
1115+
keyword_params.update(**kwargs)
1116+
return self._request_wrapper(http_method, url_path, **keyword_params)
1117+
10951118
def get_my_organizations(self, **kwargs) -> Tuple[Any, requests.Response]:
10961119
"""所属組織の一括取得
10971120
https://annofab.com/docs/api/#operation/getMyOrganizations

annofabapi/generated_api2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def get_project_member_v2(
300300
cache (str): CACHE TIMESTAMP
301301
302302
Returns:
303-
Tuple[List[ProjectMember], requests.Response]
303+
Tuple[ProjectMember, requests.Response]
304304
305305
306306
"""

annofabapi/models.py

Lines changed: 121 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,27 +2721,6 @@ class DefaultAnnotationType(Enum):
27212721
27222722
"""
27232723

2724-
GetMyMessagesResponse = Dict[str, Any]
2725-
"""
2726-
自分に届いているユーザー通知の取得結果です。
2727-
2728-
Kyes of Dict
2729-
2730-
* values: List[MyNotificationMessage]
2731-
2732-
* opened: int
2733-
開封済みの通知メッセージの数。 over_limitがtrueの場合、メッセージのタイムスタンプが新しい順から10000件のメッセージをもとに集計される
2734-
* total: int
2735-
通知メッセージの総数
2736-
* page: int
2737-
messagesに含まれる通知メッセージが何ページ目のものか
2738-
* page_total: int
2739-
ページ数の総数
2740-
* over_limit: bool
2741-
通知メッセージの取得上限を超えているか
2742-
2743-
"""
2744-
27452724

27462725
class GraphType(Enum):
27472726
"""
@@ -2785,6 +2764,30 @@ class GraphType(Enum):
27852764
27862765
"""
27872766

2767+
InitiateMfaSetupRequest = Dict[str, Any]
2768+
"""
2769+
2770+
2771+
Kyes of Dict
2772+
2773+
* access_token: str
2774+
アクセストークン。[login](#operation/login) APIで取得します。
2775+
2776+
"""
2777+
2778+
InitiateMfaSetupResponse = Dict[str, Any]
2779+
"""
2780+
2781+
2782+
Kyes of Dict
2783+
2784+
* secret_code: str
2785+
TOTPアルゴリズムでワンタイムコードを生成するために使用される、一意に生成された共有秘密コードです。
2786+
* qr_code_data: str
2787+
MFAを有効化する際、認証アプリで読み込むQRコードに埋め込むデータです。Google AuthenticatorとIIJ SmartKeyに対応しています。
2788+
2789+
"""
2790+
27882791
InputData = Dict[str, Any]
27892792
"""
27902793
入力データの情報を表すデータ構造です。
@@ -3484,6 +3487,17 @@ class Lang(Enum):
34843487
JA_JP = "ja-JP"
34853488

34863489

3490+
LoginNeedChallengeResponse = Dict[str, Any]
3491+
"""
3492+
3493+
3494+
Kyes of Dict
3495+
3496+
* session: str
3497+
セッション
3498+
3499+
"""
3500+
34873501
LoginRequest = Dict[str, Any]
34883502
"""
34893503
@@ -3497,10 +3511,36 @@ class Lang(Enum):
34973511
34983512
"""
34993513

3514+
LoginRespondToAuthChallengeRequest = Dict[str, Any]
3515+
"""
3516+
3517+
3518+
Kyes of Dict
3519+
3520+
* mfa_code: str
3521+
MFAコード。Time-based One-time Password (TOTP) のみ対応している
3522+
* session: str
3523+
[login API](#operation/login)が返したセッション
3524+
3525+
"""
3526+
35003527
LoginResponse = Dict[str, Any]
35013528
"""
35023529
35033530
3531+
Kyes of Dict
3532+
3533+
* token: Token
3534+
3535+
* session: str
3536+
セッション
3537+
3538+
"""
3539+
3540+
LoginSucceedResponse = Dict[str, Any]
3541+
"""
3542+
3543+
35043544
Kyes of Dict
35053545
35063546
* token: Token
@@ -3584,6 +3624,17 @@ class Lang(Enum):
35843624
35853625
"""
35863626

3627+
MfaSetting = Dict[str, Any]
3628+
"""
3629+
3630+
3631+
Kyes of Dict
3632+
3633+
* enabled: bool
3634+
MFAが有効か (trueの場合に有効)
3635+
3636+
"""
3637+
35873638
MyAccount = Dict[str, Any]
35883639
"""
35893640
@@ -3630,6 +3681,27 @@ class Lang(Enum):
36303681
36313682
"""
36323683

3684+
MyNotificationList = Dict[str, Any]
3685+
"""
3686+
自分に届いているユーザー通知の取得結果です。
3687+
3688+
Kyes of Dict
3689+
3690+
* messages: List[MyNotificationMessage]
3691+
3692+
* opened: int
3693+
開封済みの通知メッセージの数。 over_limitがtrueの場合、メッセージのタイムスタンプが新しい順から10000件のメッセージをもとに集計される
3694+
* total: int
3695+
通知メッセージの総数
3696+
* page: int
3697+
messagesに含まれる通知メッセージが何ページ目のものか
3698+
* page_total: int
3699+
ページ数の総数
3700+
* over_limit: bool
3701+
通知メッセージの取得上限を超えているか
3702+
3703+
"""
3704+
36333705
MyNotificationMessage = Dict[str, Any]
36343706
"""
36353707
自分への通知メッセージの情報です。
@@ -3648,6 +3720,19 @@ class Lang(Enum):
36483720
自身がメッセージを開封したか(開封済みの場合true)
36493721
* timestamp: str
36503722
最後に通知メッセージ内容を更新した日時。更新がない場合はメッセージ作成日時
3723+
* created_datetime: str
3724+
メッセージ作成日時
3725+
3726+
"""
3727+
3728+
MyNotificationUnreadMessagesCount = Dict[str, Any]
3729+
"""
3730+
通知メッセージの未読件数
3731+
3732+
Kyes of Dict
3733+
3734+
* unread: int
3735+
通知メッセージの未読件数
36513736
36523737
"""
36533738

@@ -4232,6 +4317,21 @@ class OrganizationMemberStatus(Enum):
42324317
* job: ProjectJobInfo
42334318
42344319
4320+
"""
4321+
4322+
PostMfaSettingRequest = Dict[str, Any]
4323+
"""
4324+
4325+
4326+
Kyes of Dict
4327+
4328+
* enabled: bool
4329+
MFAをONにするか
4330+
* mfa_code: str
4331+
[initiateMfaSetup](#operation/initiateMfaSetup)が返したシークレットコードを元に生成したTOTP。enabledがtrueの場合に設定する
4332+
* access_token: str
4333+
アクセストークン。enabledがtrueの場合に設定する
4334+
42354335
"""
42364336

42374337
PostProjectTasksUpdateResponse = Dict[str, Any]

0 commit comments

Comments
 (0)