Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2b71995e
Commit
2b71995e
authored
May 20, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shared_runners_minutes_limit to groups and users API
parent
ffaccec7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
6 deletions
+42
-6
lib/api/entities.rb
lib/api/entities.rb
+11
-0
lib/api/groups.rb
lib/api/groups.rb
+3
-2
lib/api/users.rb
lib/api/users.rb
+11
-4
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+8
-0
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+9
-0
No files found.
lib/api/entities.rb
View file @
2b71995e
...
...
@@ -38,6 +38,14 @@ module API
expose
:can_create_project?
,
as: :can_create_project
expose
:two_factor_enabled?
,
as: :two_factor_enabled
expose
:external
# EE-only
expose
:namespace
,
using:
'API::Entities::UserNamespace'
end
# EE-only
class
UserNamespace
<
Grape
::
Entity
expose
:shared_runners_minutes_limit
end
class
UserWithPrivateDetails
<
UserPublic
...
...
@@ -181,6 +189,9 @@ module API
class
GroupDetail
<
Group
expose
:projects
,
using:
Entities
::
Project
expose
:shared_projects
,
using:
Entities
::
Project
# EE-only
expose
:shared_runners_minutes_limit
end
class
RepoCommit
<
Grape
::
Entity
...
...
lib/api/groups.rb
View file @
2b71995e
...
...
@@ -17,6 +17,7 @@ module API
optional
:membership_lock
,
type:
Boolean
,
desc:
'Prevent adding new members to project membership within this group'
optional
:ldap_cn
,
type:
String
,
desc:
'LDAP Common Name'
optional
:ldap_access
,
type:
Integer
,
desc:
'A valid access level'
optional
:shared_runners_minutes_limit
,
type:
Integer
,
desc:
'Pipeline minutes quota for this group'
all_or_none_of
:ldap_cn
,
:ldap_access
end
...
...
@@ -118,8 +119,8 @@ module API
optional
:name
,
type:
String
,
desc:
'The name of the group'
optional
:path
,
type:
String
,
desc:
'The path of the group'
use
:optional_params
at_least_one_of
:name
,
:path
,
:description
,
:visibility
,
:lfs_enabled
,
:request_access_enabled
at_least_one_of
(
*
@declared_params
.
flatten
-
[
:id
])
end
put
':id'
do
group
=
find_group!
(
params
[
:id
])
...
...
lib/api/users.rb
View file @
2b71995e
...
...
@@ -30,6 +30,11 @@ module API
optional
:skip_confirmation
,
type:
Boolean
,
default:
false
,
desc:
'Flag indicating the account is confirmed'
optional
:external
,
type:
Boolean
,
desc:
'Flag indicating the user is an external user'
all_or_none_of
:extern_uid
,
:provider
# EE
optional
:namespace_attributes
,
type:
Hash
do
optional
:shared_runners_minutes_limit
,
type:
Integer
,
desc:
'Pipeline minutes quota for this user'
end
end
end
...
...
@@ -137,10 +142,8 @@ module API
optional
:name
,
type:
String
,
desc:
'The name of the user'
optional
:username
,
type:
String
,
desc:
'The username of the user'
use
:optional_attributes
at_least_one_of
:email
,
:password
,
:name
,
:username
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
,
:projects_limit
,
:extern_uid
,
:provider
,
:bio
,
:location
,
:admin
,
:can_create_group
,
:confirm
,
:external
at_least_one_of
(
*
@declared_params
.
flatten
-
[
:id
])
end
put
":id"
do
authenticated_as_admin!
...
...
@@ -172,6 +175,10 @@ module API
user_params
[
:password_expires_at
]
=
Time
.
now
if
user_params
[
:password
].
present?
# EE
namespace_attributes
=
user_params
[
:namespace_attributes
]
namespace_attributes
[
:id
]
=
user
.
namespace_id
if
namespace_attributes
if
user
.
update_attributes
(
user_params
.
except
(
:extern_uid
,
:provider
))
present
user
,
with:
Entities
::
UserPublic
else
...
...
spec/requests/api/groups_spec.rb
View file @
2b71995e
...
...
@@ -272,6 +272,14 @@ describe API::Groups do
expect
(
response
).
to
have_http_status
(
404
)
end
# EE
it
'updates the group for shared_runners_minutes_limit'
do
put
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
),
shared_runners_minutes_limit:
133
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'shared_runners_minutes_limit'
]).
to
eq
(
133
)
end
end
context
'when authenticated as the admin'
do
...
...
spec/requests/api/users_spec.rb
View file @
2b71995e
...
...
@@ -425,6 +425,15 @@ describe API::Users do
expect
(
user
.
reload
.
external?
).
to
be_truthy
end
it
"updates shared_runners_minutes_limit"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
{
namespace_attributes:
{
shared_runners_minutes_limit:
133
}
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
.
dig
(
'namespace'
,
'shared_runners_minutes_limit'
))
.
to
eq
(
133
)
expect
(
user
.
reload
.
namespace
.
shared_runners_minutes_limit
).
to
eq
(
133
)
end
it
"does not update admin status"
do
put
api
(
"/users/
#{
admin_user
.
id
}
"
,
admin
),
{
can_create_group:
false
}
expect
(
response
).
to
have_http_status
(
200
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment