harbor-go-client
harbor-go-client copied to clipboard
[NOTE] Comments on "POST /projects/{project_id}/members" API
by swagger file definition, user can create member relationship for a project with "POST /projects/{project_id}/members".
Currently, user_member
is supported, that is, you can only update role_id
with one of user_id
and username
, or both. Take user_id
for higher priority.
case 1
Funny thing is that you can always update successfully with user_id
, no matter whether it is a right value.
So, these two below cause no errors:
{
"role_id": 1,
"member_user": {
"user_id": 15 // right one
}
}
{
"role_id": 1,
"member_user": {
"user_id": 1500 // wrong one
}
}
case 2
By contrast, you can only update successfully with a right username
.
{
"role_id": 1,
"member_user": {
"username": "fei.sun"
}
}
{
"role_id": 1,
"member_user": {
"username": "fei.zhang"
}
}
case 3
If you can call this API with both user_id
and username
, the latter one is simply ignored. (it is equivalent to case 1)
{
"role_id": 1,
"member_user": {
"username": "fei.zhang",
"user_id": 15
}
}
Simply speaking, API "POST /projects/{project_id}/members" acts as both create and update functioning.
NOTE:
该 API 有向 project 添加新 member 的动作;添加成功后,还可以利用该 API 更新目标 member 的 role (可以理解为该 API 的副作用);而更新 role 的动作实际上是通过另一个 API "PUT /projects/{project_id}/members/{mid}" 支持的,该 API 需要一个 mid 参数,是在 create 后自动生成的,需要通过 API "GET /projects/{project_id}/members" 才能得到;