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
2465848b
Commit
2465848b
authored
Feb 21, 2019
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move EE code out if API::Entities
parent
e5d8ca9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
24 deletions
+38
-24
ee/lib/api/managed_licenses.rb
ee/lib/api/managed_licenses.rb
+9
-9
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+27
-0
lib/api/entities.rb
lib/api/entities.rb
+2
-15
No files found.
ee/lib/api/managed_licenses.rb
View file @
2465848b
...
...
@@ -29,7 +29,7 @@ module API
resource
:projects
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
desc
'Get project software license policies'
do
success
Entities
::
ManagedLicense
success
E
E
::
API
::
E
ntities
::
ManagedLicense
end
route_setting
:skip_authentication
,
true
params
do
...
...
@@ -39,21 +39,21 @@ module API
authorize_can_read!
software_license_policies
=
user_project
.
software_license_policies
present
paginate
(
software_license_policies
),
with:
Entities
::
ManagedLicense
present
paginate
(
software_license_policies
),
with:
E
E
::
API
::
E
ntities
::
ManagedLicense
end
desc
'Get a specific software license policy from a project'
do
success
Entities
::
ManagedLicense
success
E
E
::
API
::
E
ntities
::
ManagedLicense
end
get
':id/managed_licenses/:managed_license_id'
,
requirements:
{
managed_license_id:
/.*/
}
do
authorize_can_read!
break
not_found!
(
'SoftwareLicensePolicy'
)
unless
software_license_policy
present
software_license_policy
,
with:
Entities
::
ManagedLicense
present
software_license_policy
,
with:
E
E
::
API
::
E
ntities
::
ManagedLicense
end
desc
'Create a new software license policy in a project'
do
success
Entities
::
ManagedLicense
success
E
E
::
API
::
E
ntities
::
ManagedLicense
end
params
do
requires
:name
,
type:
String
,
desc:
'The name of the license'
...
...
@@ -73,14 +73,14 @@ module API
created_software_license_policy
=
result
[
:software_license_policy
]
if
result
[
:status
]
==
:success
present
created_software_license_policy
,
with:
Entities
::
ManagedLicense
present
created_software_license_policy
,
with:
E
E
::
API
::
E
ntities
::
ManagedLicense
else
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
end
end
desc
'Update an existing software license policy from a project'
do
success
Entities
::
ManagedLicense
success
E
E
::
API
::
E
ntities
::
ManagedLicense
end
params
do
optional
:name
,
type:
String
,
desc:
'The name of the license'
...
...
@@ -101,7 +101,7 @@ module API
).
execute
(
@software_license_policy
)
if
result
[
:status
]
==
:success
present
@software_license_policy
,
with:
Entities
::
ManagedLicense
present
@software_license_policy
,
with:
E
E
::
API
::
E
ntities
::
ManagedLicense
else
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
end
...
...
@@ -109,7 +109,7 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
desc
'Delete an existing software license policy from a project'
do
success
Entities
::
ManagedLicense
success
E
E
::
API
::
E
ntities
::
ManagedLicense
end
delete
':id/managed_licenses/:managed_license_id'
,
requirements:
{
managed_license_id:
/.*/
}
do
authorize_can_admin!
...
...
ee/lib/ee/api/entities.rb
View file @
2465848b
...
...
@@ -6,6 +6,21 @@ module EE
#######################
# Entities extensions #
#######################
module
Entities
extend
ActiveSupport
::
Concern
class_methods
do
def
prepend_entity
(
klass
,
with:
nil
)
if
with
.
nil?
raise
ArgumentError
,
'You need to pass either the :with or :namespace option!'
end
klass
.
descendants
.
each
{
|
descendant
|
descendant
.
prepend
(
with
)
}
klass
.
prepend
(
with
)
end
end
end
module
UserPublic
extend
ActiveSupport
::
Concern
...
...
@@ -63,6 +78,14 @@ module EE
end
end
module
ProtectedBranch
extend
ActiveSupport
::
Concern
prepended
do
expose
:unprotect_access_levels
,
using:
::
API
::
Entities
::
ProtectedRefAccess
end
end
module
IssueBasic
extend
ActiveSupport
::
Concern
...
...
@@ -650,6 +673,10 @@ module EE
expose
:file_name
,
:size
expose
:file_md5
,
:file_sha1
end
class
ManagedLicense
<
Grape
::
Entity
expose
:id
,
:name
,
:approval_status
end
end
end
end
lib/api/entities.rb
View file @
2465848b
...
...
@@ -504,7 +504,6 @@ module API
class
ProtectedRefAccess
<
Grape
::
Entity
expose
:access_level
expose
:access_level_description
do
|
protected_ref_access
|
protected_ref_access
.
humanize
end
...
...
@@ -514,7 +513,6 @@ module API
expose
:name
expose
:push_access_levels
,
using:
Entities
::
ProtectedRefAccess
expose
:merge_access_levels
,
using:
Entities
::
ProtectedRefAccess
expose
:unprotect_access_levels
,
using:
Entities
::
ProtectedRefAccess
end
class
ProtectedTag
<
Grape
::
Entity
...
...
@@ -1539,19 +1537,6 @@ module API
end
end
def
self
.
prepend_entity
(
klass
,
with:
nil
)
if
with
.
nil?
raise
ArgumentError
,
'You need to pass either the :with or :namespace option!'
end
klass
.
descendants
.
each
{
|
descendant
|
descendant
.
prepend
(
with
)
}
klass
.
prepend
(
with
)
end
class
ManagedLicense
<
Grape
::
Entity
expose
:id
,
:name
,
:approval_status
end
class
ResourceLabelEvent
<
Grape
::
Entity
expose
:id
expose
:user
,
using:
Entities
::
UserBasic
...
...
@@ -1613,6 +1598,7 @@ module API
end
end
API
::
Entities
.
prepend
(
EE
::
API
::
Entities
::
Entities
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
API
::
Entities
.
prepend_entity
(
::
API
::
Entities
::
ApplicationSetting
,
with:
EE
::
API
::
Entities
::
ApplicationSetting
)
API
::
Entities
.
prepend_entity
(
::
API
::
Entities
::
Board
,
with:
EE
::
API
::
Entities
::
Board
)
API
::
Entities
.
prepend_entity
(
::
API
::
Entities
::
Group
,
with:
EE
::
API
::
Entities
::
Group
)
...
...
@@ -1626,3 +1612,4 @@ API::Entities.prepend_entity(::API::Entities::ProtectedRefAccess, with: EE::API:
API
::
Entities
.
prepend_entity
(
::
API
::
Entities
::
UserPublic
,
with:
EE
::
API
::
Entities
::
UserPublic
)
API
::
Entities
.
prepend_entity
(
::
API
::
Entities
::
Variable
,
with:
EE
::
API
::
Entities
::
Variable
)
API
::
Entities
.
prepend_entity
(
::
API
::
Entities
::
Todo
,
with:
EE
::
API
::
Entities
::
Todo
)
API
::
Entities
.
prepend_entity
(
::
API
::
Entities
::
ProtectedBranch
,
with:
EE
::
API
::
Entities
::
ProtectedBranch
)
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