Commit ce40c128 authored by manojmj's avatar manojmj

CE: Read and write User "Admin notes" via API

This change adds the ability to read and
write admin notes for a user via the
USER API
parent 3a55ba7d
...@@ -147,6 +147,21 @@ GET /users ...@@ -147,6 +147,21 @@ GET /users
] ]
``` ```
Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) will also see the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, and `note` parameters.
```json
[
{
"id": 1,
...
"shared_runners_minutes_limit": 133,
"extra_shared_runners_minutes_limit": 133,
"note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123"
...
}
]
```
Users on GitLab [Silver or higher](https://about.gitlab.com/pricing/) will also see Users on GitLab [Silver or higher](https://about.gitlab.com/pricing/) will also see
the `group_saml` provider option: the `group_saml` provider option:
...@@ -284,14 +299,15 @@ Example Responses: ...@@ -284,14 +299,15 @@ Example Responses:
``` ```
Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) will also see Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) will also see
the `shared_runners_minutes_limit` and `extra_shared_runners_minutes_limit` parameters. the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, and `note` parameters.
```json ```json
{ {
"id": 1, "id": 1,
"username": "john_smith", "username": "john_smith",
"shared_runners_minutes_limit": 133, "shared_runners_minutes_limit": 133,
"extra_shared_runners_minutes_limit": 133 "extra_shared_runners_minutes_limit": 133,
"note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123"
... ...
} }
``` ```
...@@ -304,7 +320,8 @@ see the `group_saml` option: ...@@ -304,7 +320,8 @@ see the `group_saml` option:
"id": 1, "id": 1,
"username": "john_smith", "username": "john_smith",
"shared_runners_minutes_limit": 133, "shared_runners_minutes_limit": 133,
"extra_shared_runners_minutes_limit": 133 "extra_shared_runners_minutes_limit": 133,
"note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123"
"identities": [ "identities": [
{"provider": "github", "extern_uid": "2435223452345"}, {"provider": "github", "extern_uid": "2435223452345"},
{"provider": "bitbucket", "extern_uid": "john.smith"}, {"provider": "bitbucket", "extern_uid": "john.smith"},
...@@ -399,6 +416,7 @@ Parameters: ...@@ -399,6 +416,7 @@ Parameters:
- `private_profile` (optional) - User's profile is private - true or false - `private_profile` (optional) - User's profile is private - true or false
- `shared_runners_minutes_limit` (optional) - Pipeline minutes quota for this user **(STARTER)** - `shared_runners_minutes_limit` (optional) - Pipeline minutes quota for this user **(STARTER)**
- `extra_shared_runners_minutes_limit` (optional) - Extra pipeline minutes quota for this user **(STARTER)** - `extra_shared_runners_minutes_limit` (optional) - Extra pipeline minutes quota for this user **(STARTER)**
- `note` (optional) - Admin notes for this user **(STARTER)**
On password update, user will be forced to change it upon next login. On password update, user will be forced to change it upon next login.
Note, at the moment this method does only return a `404` error, Note, at the moment this method does only return a `404` error,
......
...@@ -148,7 +148,7 @@ module API ...@@ -148,7 +148,7 @@ module API
end end
desc 'Create a user. Available only for admins.' do desc 'Create a user. Available only for admins.' do
success Entities::UserPublic success Entities::UserWithAdmin
end end
params do params do
requires :email, type: String, desc: 'The email of the user' requires :email, type: String, desc: 'The email of the user'
...@@ -168,7 +168,7 @@ module API ...@@ -168,7 +168,7 @@ module API
user = ::Users::CreateService.new(current_user, params).execute(skip_authorization: true) user = ::Users::CreateService.new(current_user, params).execute(skip_authorization: true)
if user.persisted? if user.persisted?
present user, with: Entities::UserPublic, current_user: current_user present user, with: Entities::UserWithAdmin, current_user: current_user
else else
conflict!('Email has already been taken') if User conflict!('Email has already been taken') if User
.by_any_email(user.email.downcase) .by_any_email(user.email.downcase)
...@@ -183,7 +183,7 @@ module API ...@@ -183,7 +183,7 @@ module API
end end
desc 'Update a user. Available only for admins.' do desc 'Update a user. Available only for admins.' do
success Entities::UserPublic success Entities::UserWithAdmin
end end
params do params do
requires :id, type: Integer, desc: 'The ID of the user' requires :id, type: Integer, desc: 'The ID of the user'
...@@ -215,7 +215,7 @@ module API ...@@ -215,7 +215,7 @@ module API
result = ::Users::UpdateService.new(current_user, user_params.merge(user: user)).execute result = ::Users::UpdateService.new(current_user, user_params.merge(user: user)).execute
if result[:status] == :success if result[:status] == :success
present user, with: Entities::UserPublic, current_user: current_user present user, with: Entities::UserWithAdmin, current_user: current_user
else else
render_validation_error!(user) render_validation_error!(user)
end end
......
...@@ -448,6 +448,7 @@ describe API::Users do ...@@ -448,6 +448,7 @@ describe API::Users do
it "returns 201 Created on success" do it "returns 201 Created on success" do
post api("/users", admin), params: attributes_for(:user, projects_limit: 3) post api("/users", admin), params: attributes_for(:user, projects_limit: 3)
expect(response).to match_response_schema('public_api/v4/user/admin')
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
end end
...@@ -643,6 +644,13 @@ describe API::Users do ...@@ -643,6 +644,13 @@ describe API::Users do
describe "PUT /users/:id" do describe "PUT /users/:id" do
let!(:admin_user) { create(:admin) } let!(:admin_user) { create(:admin) }
it "returns 200 OK on success" do
put api("/users/#{user.id}", admin), params: { bio: 'new test bio' }
expect(response).to match_response_schema('public_api/v4/user/admin')
expect(response).to have_gitlab_http_status(200)
end
it "updates user with new bio" do it "updates user with new bio" do
put api("/users/#{user.id}", admin), params: { bio: 'new test bio' } put api("/users/#{user.id}", admin), params: { bio: 'new test bio' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment