Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] 用户管理支持HTTP 数据源协议 #363

Closed
wklken opened this issue Apr 14, 2022 · 5 comments
Closed

[API] 用户管理支持HTTP 数据源协议 #363

wklken opened this issue Apr 14, 2022 · 5 comments
Assignees
Labels
Layer: api Api module related Priority: High Type: enhancement Enhancement for existing feature

Comments

@wklken
Copy link
Collaborator

wklken commented Apr 14, 2022

用户: 两个环境之间用户管理的数据同步

协议: https://github.com/TencentBlueKing/bk-user/blob/master/src/api/bkuser_core/categories/plugins/custom/README.md

URL:

  • /api/v2/categories/1/profiles/
  • /api/v2/categories/1/departments/
@wklken wklken added Type: enhancement Enhancement for existing feature Layer: api Api module related Priority: High labels Apr 14, 2022
@wklken wklken self-assigned this Apr 14, 2022
@wklken
Copy link
Collaborator Author

wklken commented Apr 14, 2022

需要考虑, 如何确保数据一致性

a -> b -> c

@wklken
Copy link
Collaborator Author

wklken commented Apr 15, 2022

目前 MAX_PAGE_SIZE = env.int("MAX_PAGE_SIZE", default=2000)

环境, 调大

$ curl -X GET "http://127.0.0.1:8004/api/v2/departments/?page=1&page_size=100000&fields=name%2Ccode%2Cparent&best_match=false&time_field=create_time&lookup_field=category_id&exact_lookups=2" -H  "accept: application/json" | jq
curl -X GET "http://127.0.0.1:8004/api/v2/profiles/?page=1&page_size=1000&fields=username%2Ccode%2Cdisplay_name%2Cdepartments&lookup_field=category_id&exact_lookups=2&best_match=false&time_field=create_time&include_disabled=false" -H  "accept: application/json" -H  "X-CSRFToken: RAFRoeMfRLZ5P3DA9wgWi5WlDsS2Bgta4M6mxWGsZZKann7EJvQS8JUOaEqkBhGb" | jq

返回协议不符合要求, 要改
1. 没有返回code
2. departments 不是departments的code的列表

@wklken
Copy link
Collaborator Author

wklken commented Apr 18, 2022

curl -X GET "http://127.0.0.1:8004/api/v2/departments/?page=1&page_size=100000&fields=name%2Ccode%2Cparent&best_match=false&time_field=create_time&lookup_field=category_id&exact_lookups=2&for_sync=true" -H  "accept: application/json"  | jq

curl -X GET "http://127.0.0.1:8004/api/v2/profiles/?page=1&page_size=1000&fields=username%2Ccode%2Cdisplay_name%2Cdepartments&lookup_field=category_id&exact_lookups=2&best_match=false&time_field=create_time&for_sync=true" -H  "accept: application/json" | jq


@wklken
Copy link
Collaborator Author

wklken commented Apr 19, 2022

#368

@wklken wklken closed this as completed Apr 19, 2022
@wklken
Copy link
Collaborator Author

wklken commented Apr 19, 2022

examples

# departments
{
  "count": 2,
  "results": [
    {
      "name": "部门A",
      "code": "3254854d4e7cbfd94a3a7ffe6fb0af9efbc6ea37cf5b25d4a2a63ece8d44bf42",
      "parent": null
    },
    {
      "name": "部门B",
      "code": "f7897c3a552649c52301b1df07e0759a3e3d71d7ae53f3e30f188180f531ceb1",
      "parent": null
    }
  ]
}

# profiles
{
  "count": 2,
  "results": [
    {
      "username": "jack",
      "display_name": "杰克",
      "departments": [
        "3254854d4e7cbfd94a3a7ffe6fb0af9efbc6ea37cf5b25d4a2a63ece8d44bf42"
      ],
      "code": "c0d9714f4623c9b5ad7227cc04900cb22f6a113fbd1f8d6b0a3ac144abdac1b5"
    },
    {
      "username": "tom",
      "display_name": "汤姆",
      "departments": [
        "3254854d4e7cbfd94a3a7ffe6fb0af9efbc6ea37cf5b25d4a2a63ece8d44bf42",
        "f7897c3a552649c52301b1df07e0759a3e3d71d7ae53f3e30f188180f531ceb1"
      ],
      "code": "24309eccb2bd00601e8cfd5bf0f2c96b1a127c7c09eabdff2ad41644a81cb230"
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: api Api module related Priority: High Type: enhancement Enhancement for existing feature
Projects
None yet
Development

No branches or pull requests

1 participant