harbor-go-client icon indicating copy to clipboard operation
harbor-go-client copied to clipboard

[NOTE] Comments on "POST /projects/{project_id}/members" API

Open moooofly opened this issue 6 years ago • 1 comments

by swagger file definition, user can create member relationship for a project with "POST /projects/{project_id}/members".

image

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.

image

image


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
  }
}

image

{
  "role_id": 1,
  "member_user": {
    "user_id": 1500  // wrong one
  }
}

image

case 2

By contrast, you can only update successfully with a right username.

{
  "role_id": 1,
  "member_user": {
    "username": "fei.sun"
  }
}

image

{
  "role_id": 1,
  "member_user": {
    "username": "fei.zhang"
  }
}

image

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
  }
}

image

moooofly avatar Oct 31 '18 11:10 moooofly

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" 才能得到;

moooofly avatar Oct 31 '18 11:10 moooofly