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
df9f1676
Commit
df9f1676
authored
Aug 13, 2020
by
Allison Browne
Committed by
Robert Speicher
Aug 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Entities to ci namespace
Move job variable and pipeline entities
parent
19240517
Changes
35
Show whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
247 additions
and
188 deletions
+247
-188
ee/app/serializers/blocking_merge_request_entity.rb
ee/app/serializers/blocking_merge_request_entity.rb
+1
-1
ee/lib/ee/api/entities/merge_train.rb
ee/lib/ee/api/entities/merge_train.rb
+1
-1
lib/api/admin/ci/variables.rb
lib/api/admin/ci/variables.rb
+9
-9
lib/api/ci/pipeline_schedules.rb
lib/api/ci/pipeline_schedules.rb
+17
-17
lib/api/ci/pipelines.rb
lib/api/ci/pipelines.rb
+14
-14
lib/api/ci/runners.rb
lib/api/ci/runners.rb
+2
-2
lib/api/entities/ci/bridge.rb
lib/api/entities/ci/bridge.rb
+11
-0
lib/api/entities/ci/job.rb
lib/api/entities/ci/job.rb
+15
-0
lib/api/entities/ci/job_artifact.rb
lib/api/entities/ci/job_artifact.rb
+11
-0
lib/api/entities/ci/job_artifact_file.rb
lib/api/entities/ci/job_artifact_file.rb
+12
-0
lib/api/entities/ci/job_basic.rb
lib/api/entities/ci/job_basic.rb
+20
-0
lib/api/entities/ci/job_basic_with_project.rb
lib/api/entities/ci/job_basic_with_project.rb
+11
-0
lib/api/entities/ci/pipeline.rb
lib/api/entities/ci/pipeline.rb
+19
-0
lib/api/entities/ci/pipeline_basic.rb
lib/api/entities/ci/pipeline_basic.rb
+16
-0
lib/api/entities/ci/pipeline_schedule.rb
lib/api/entities/ci/pipeline_schedule.rb
+14
-0
lib/api/entities/ci/pipeline_schedule_details.rb
lib/api/entities/ci/pipeline_schedule_details.rb
+12
-0
lib/api/entities/ci/variable.rb
lib/api/entities/ci/variable.rb
+14
-0
lib/api/entities/commit_detail.rb
lib/api/entities/commit_detail.rb
+1
-1
lib/api/entities/deployment.rb
lib/api/entities/deployment.rb
+1
-1
lib/api/entities/job.rb
lib/api/entities/job.rb
+0
-13
lib/api/entities/job_basic.rb
lib/api/entities/job_basic.rb
+0
-18
lib/api/entities/job_request/dependency.rb
lib/api/entities/job_request/dependency.rb
+1
-1
lib/api/entities/merge_request.rb
lib/api/entities/merge_request.rb
+2
-2
lib/api/entities/package/pipeline.rb
lib/api/entities/package/pipeline.rb
+1
-1
lib/api/entities/pipeline.rb
lib/api/entities/pipeline.rb
+0
-17
lib/api/entities/pipeline_basic.rb
lib/api/entities/pipeline_basic.rb
+0
-14
lib/api/entities/pipeline_schedule.rb
lib/api/entities/pipeline_schedule.rb
+0
-12
lib/api/entities/pipeline_schedule_details.rb
lib/api/entities/pipeline_schedule_details.rb
+0
-10
lib/api/entities/variable.rb
lib/api/entities/variable.rb
+0
-12
lib/api/group_variables.rb
lib/api/group_variables.rb
+9
-9
lib/api/job_artifacts.rb
lib/api/job_artifacts.rb
+2
-2
lib/api/jobs.rb
lib/api/jobs.rb
+16
-16
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+4
-4
lib/api/triggers.rb
lib/api/triggers.rb
+2
-2
lib/api/variables.rb
lib/api/variables.rb
+9
-9
No files found.
ee/app/serializers/blocking_merge_request_entity.rb
View file @
df9f1676
...
...
@@ -22,7 +22,7 @@ class BlockingMergeRequestEntity < Grape::Entity
expose
:head_pipeline
,
if:
->
(
_
,
_
)
{
can_read_head_pipeline?
},
using:
::
API
::
Entities
::
Pipeline
using:
::
API
::
Entities
::
Ci
::
Pipeline
expose
:assignees
,
using:
::
API
::
Entities
::
UserBasic
expose
:milestone
,
using:
::
API
::
Entities
::
Milestone
...
...
ee/lib/ee/api/entities/merge_train.rb
View file @
df9f1676
...
...
@@ -7,7 +7,7 @@ module EE
expose
:id
expose
:merge_request
,
using:
::
API
::
Entities
::
MergeRequestSimple
expose
:user
,
using:
::
API
::
Entities
::
UserBasic
expose
:pipeline
,
using:
::
API
::
Entities
::
PipelineBasic
expose
:pipeline
,
using:
::
API
::
Entities
::
Ci
::
PipelineBasic
expose
:created_at
expose
:updated_at
expose
:target_branch
...
...
lib/api/admin/ci/variables.rb
View file @
df9f1676
...
...
@@ -12,7 +12,7 @@ module API
namespace
'ci'
do
namespace
'variables'
do
desc
'Get instance-level variables'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
use
:pagination
...
...
@@ -20,11 +20,11 @@ module API
get
'/'
do
variables
=
::
Ci
::
InstanceVariable
.
all
present
paginate
(
variables
),
with:
Entities
::
Variable
present
paginate
(
variables
),
with:
Entities
::
Ci
::
Variable
end
desc
'Get a specific variable from a group'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
@@ -35,11 +35,11 @@ module API
break
not_found!
(
'InstanceVariable'
)
unless
variable
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
end
desc
'Create a new instance-level variable'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
...
...
@@ -69,14 +69,14 @@ module API
variable
=
::
Ci
::
InstanceVariable
.
new
(
variable_params
)
if
variable
.
save
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
else
render_validation_error!
(
variable
)
end
end
desc
'Update an existing instance-variable'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
optional
:key
,
...
...
@@ -108,14 +108,14 @@ module API
variable_params
=
declared_params
(
include_missing:
false
).
except
(
:key
)
if
variable
.
update
(
variable_params
)
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
else
render_validation_error!
(
variable
)
end
end
desc
'Delete an existing instance-level variable'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
lib/api/ci/pipeline_schedules.rb
View file @
df9f1676
...
...
@@ -12,7 +12,7 @@ module API
end
resource
:projects
,
requirements:
::
API
::
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
desc
'Get all pipeline schedules'
do
success
Entities
::
PipelineSchedule
success
Entities
::
Ci
::
PipelineSchedule
end
params
do
use
:pagination
...
...
@@ -25,22 +25,22 @@ module API
schedules
=
::
Ci
::
PipelineSchedulesFinder
.
new
(
user_project
).
execute
(
scope:
params
[
:scope
])
.
preload
([
:owner
,
:last_pipeline
])
present
paginate
(
schedules
),
with:
Entities
::
PipelineSchedule
present
paginate
(
schedules
),
with:
Entities
::
Ci
::
PipelineSchedule
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Get a single pipeline schedule'
do
success
Entities
::
PipelineScheduleDetails
success
Entities
::
Ci
::
PipelineScheduleDetails
end
params
do
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
end
get
':id/pipeline_schedules/:pipeline_schedule_id'
do
present
pipeline_schedule
,
with:
Entities
::
PipelineScheduleDetails
present
pipeline_schedule
,
with:
Entities
::
Ci
::
PipelineScheduleDetails
end
desc
'Create a new pipeline schedule'
do
success
Entities
::
PipelineScheduleDetails
success
Entities
::
Ci
::
PipelineScheduleDetails
end
params
do
requires
:description
,
type:
String
,
desc:
'The description of pipeline schedule'
...
...
@@ -57,14 +57,14 @@ module API
.
execute
if
pipeline_schedule
.
persisted?
present
pipeline_schedule
,
with:
Entities
::
PipelineScheduleDetails
present
pipeline_schedule
,
with:
Entities
::
Ci
::
PipelineScheduleDetails
else
render_validation_error!
(
pipeline_schedule
)
end
end
desc
'Edit a pipeline schedule'
do
success
Entities
::
PipelineScheduleDetails
success
Entities
::
Ci
::
PipelineScheduleDetails
end
params
do
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
...
...
@@ -78,14 +78,14 @@ module API
authorize!
:update_pipeline_schedule
,
pipeline_schedule
if
pipeline_schedule
.
update
(
declared_params
(
include_missing:
false
))
present
pipeline_schedule
,
with:
Entities
::
PipelineScheduleDetails
present
pipeline_schedule
,
with:
Entities
::
Ci
::
PipelineScheduleDetails
else
render_validation_error!
(
pipeline_schedule
)
end
end
desc
'Take ownership of a pipeline schedule'
do
success
Entities
::
PipelineScheduleDetails
success
Entities
::
Ci
::
PipelineScheduleDetails
end
params
do
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
...
...
@@ -94,14 +94,14 @@ module API
authorize!
:update_pipeline_schedule
,
pipeline_schedule
if
pipeline_schedule
.
own!
(
current_user
)
present
pipeline_schedule
,
with:
Entities
::
PipelineScheduleDetails
present
pipeline_schedule
,
with:
Entities
::
Ci
::
PipelineScheduleDetails
else
render_validation_error!
(
pipeline_schedule
)
end
end
desc
'Delete a pipeline schedule'
do
success
Entities
::
PipelineScheduleDetails
success
Entities
::
Ci
::
PipelineScheduleDetails
end
params
do
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
...
...
@@ -132,7 +132,7 @@ module API
end
desc
'Create a new pipeline schedule variable'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
...
...
@@ -146,14 +146,14 @@ module API
variable_params
=
declared_params
(
include_missing:
false
)
variable
=
pipeline_schedule
.
variables
.
create
(
variable_params
)
if
variable
.
persisted?
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
else
render_validation_error!
(
variable
)
end
end
desc
'Edit a pipeline schedule variable'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
...
...
@@ -165,14 +165,14 @@ module API
authorize!
:update_pipeline_schedule
,
pipeline_schedule
if
pipeline_schedule_variable
.
update
(
declared_params
(
include_missing:
false
))
present
pipeline_schedule_variable
,
with:
Entities
::
Variable
present
pipeline_schedule_variable
,
with:
Entities
::
Ci
::
Variable
else
render_validation_error!
(
pipeline_schedule_variable
)
end
end
desc
'Delete a pipeline schedule variable'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
...
...
@@ -182,7 +182,7 @@ module API
authorize!
:admin_pipeline_schedule
,
pipeline_schedule
status
:accepted
present
pipeline_schedule_variable
.
destroy
,
with:
Entities
::
Variable
present
pipeline_schedule_variable
.
destroy
,
with:
Entities
::
Ci
::
Variable
end
end
...
...
lib/api/ci/pipelines.rb
View file @
df9f1676
...
...
@@ -13,7 +13,7 @@ module API
resource
:projects
,
requirements:
::
API
::
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
desc
'Get all Pipelines of the project'
do
detail
'This feature was introduced in GitLab 8.11.'
success
Entities
::
PipelineBasic
success
Entities
::
Ci
::
PipelineBasic
end
params
do
use
:pagination
...
...
@@ -38,12 +38,12 @@ module API
authorize!
:read_build
,
user_project
pipelines
=
::
Ci
::
PipelinesFinder
.
new
(
user_project
,
current_user
,
params
).
execute
present
paginate
(
pipelines
),
with:
Entities
::
PipelineBasic
present
paginate
(
pipelines
),
with:
Entities
::
Ci
::
PipelineBasic
end
desc
'Create a new pipeline'
do
detail
'This feature was introduced in GitLab 8.14'
success
Entities
::
Pipeline
success
Entities
::
Ci
::
Pipeline
end
params
do
requires
:ref
,
type:
String
,
desc:
'Reference'
...
...
@@ -64,7 +64,7 @@ module API
.
execute
(
:api
,
ignore_skip_ci:
true
,
save_on_errors:
false
)
if
new_pipeline
.
persisted?
present
new_pipeline
,
with:
Entities
::
Pipeline
present
new_pipeline
,
with:
Entities
::
Ci
::
Pipeline
else
render_validation_error!
(
new_pipeline
)
end
...
...
@@ -72,7 +72,7 @@ module API
desc
'Gets a the latest pipeline for the project branch'
do
detail
'This feature was introduced in GitLab 12.3'
success
Entities
::
Pipeline
success
Entities
::
Ci
::
Pipeline
end
params
do
optional
:ref
,
type:
String
,
desc:
'branch ref of pipeline'
...
...
@@ -80,12 +80,12 @@ module API
get
':id/pipelines/latest'
do
authorize!
:read_pipeline
,
latest_pipeline
present
latest_pipeline
,
with:
Entities
::
Pipeline
present
latest_pipeline
,
with:
Entities
::
Ci
::
Pipeline
end
desc
'Gets a specific pipeline for the project'
do
detail
'This feature was introduced in GitLab 8.11'
success
Entities
::
Pipeline
success
Entities
::
Ci
::
Pipeline
end
params
do
requires
:pipeline_id
,
type:
Integer
,
desc:
'The pipeline ID'
...
...
@@ -93,12 +93,12 @@ module API
get
':id/pipelines/:pipeline_id'
do
authorize!
:read_pipeline
,
pipeline
present
pipeline
,
with:
Entities
::
Pipeline
present
pipeline
,
with:
Entities
::
Ci
::
Pipeline
end
desc
'Gets the variables for a given pipeline'
do
detail
'This feature was introduced in GitLab 11.11'
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:pipeline_id
,
type:
Integer
,
desc:
'The pipeline ID'
...
...
@@ -106,7 +106,7 @@ module API
get
':id/pipelines/:pipeline_id/variables'
do
authorize!
:read_pipeline_variable
,
pipeline
present
pipeline
.
variables
,
with:
Entities
::
Variable
present
pipeline
.
variables
,
with:
Entities
::
Ci
::
Variable
end
desc
'Gets the test report for a given pipeline'
do
...
...
@@ -141,7 +141,7 @@ module API
desc
'Retry builds in the pipeline'
do
detail
'This feature was introduced in GitLab 8.11.'
success
Entities
::
Pipeline
success
Entities
::
Ci
::
Pipeline
end
params
do
requires
:pipeline_id
,
type:
Integer
,
desc:
'The pipeline ID'
...
...
@@ -151,12 +151,12 @@ module API
pipeline
.
retry_failed
(
current_user
)
present
pipeline
,
with:
Entities
::
Pipeline
present
pipeline
,
with:
Entities
::
Ci
::
Pipeline
end
desc
'Cancel all builds in the pipeline'
do
detail
'This feature was introduced in GitLab 8.11.'
success
Entities
::
Pipeline
success
Entities
::
Ci
::
Pipeline
end
params
do
requires
:pipeline_id
,
type:
Integer
,
desc:
'The pipeline ID'
...
...
@@ -167,7 +167,7 @@ module API
pipeline
.
cancel_running
status
200
present
pipeline
.
reset
,
with:
Entities
::
Pipeline
present
pipeline
.
reset
,
with:
Entities
::
Ci
::
Pipeline
end
end
...
...
lib/api/ci/runners.rb
View file @
df9f1676
...
...
@@ -111,7 +111,7 @@ module API
end
desc
'List jobs running on a runner'
do
success
Entities
::
JobBasicWithProject
success
Entities
::
Ci
::
JobBasicWithProject
end
params
do
requires
:id
,
type:
Integer
,
desc:
'The ID of the runner'
...
...
@@ -126,7 +126,7 @@ module API
jobs
=
::
Ci
::
RunnerJobsFinder
.
new
(
runner
,
params
).
execute
present
paginate
(
jobs
),
with:
Entities
::
JobBasicWithProject
present
paginate
(
jobs
),
with:
Entities
::
Ci
::
JobBasicWithProject
end
end
...
...
lib/api/entities/bridge.rb
→
lib/api/entities/
ci/
bridge.rb
View file @
df9f1676
...
...
@@ -2,8 +2,10 @@
module
API
module
Entities
class
Bridge
<
Entities
::
JobBasic
expose
:downstream_pipeline
,
with:
Entities
::
PipelineBasic
module
Ci
class
Bridge
<
JobBasic
expose
:downstream_pipeline
,
with:
::
API
::
Entities
::
Ci
::
PipelineBasic
end
end
end
end
lib/api/entities/ci/job.rb
0 → 100644
View file @
df9f1676
# frozen_string_literal: true
module
API
module
Entities
module
Ci
class
Job
<
JobBasic
# artifacts_file is included in job_artifacts, but kept for backward compatibility (remove in api/v5)
expose
:artifacts_file
,
using:
::
API
::
Entities
::
Ci
::
JobArtifactFile
,
if:
->
(
job
,
opts
)
{
job
.
artifacts?
}
expose
:job_artifacts
,
as: :artifacts
,
using:
::
API
::
Entities
::
Ci
::
JobArtifact
expose
:runner
,
with:
::
API
::
Entities
::
Runner
expose
:artifacts_expire_at
end
end
end
end
lib/api/entities/job_artifact.rb
→
lib/api/entities/
ci/
job_artifact.rb
View file @
df9f1676
...
...
@@ -2,8 +2,10 @@
module
API
module
Entities
module
Ci
class
JobArtifact
<
Grape
::
Entity
expose
:file_type
,
:size
,
:filename
,
:file_format
end
end
end
end
lib/api/entities/job_artifact_file.rb
→
lib/api/entities/
ci/
job_artifact_file.rb
View file @
df9f1676
...
...
@@ -2,9 +2,11 @@
module
API
module
Entities
module
Ci
class
JobArtifactFile
<
Grape
::
Entity
expose
:filename
expose
:cached_size
,
as: :size
end
end
end
end
lib/api/entities/ci/job_basic.rb
0 → 100644
View file @
df9f1676
# frozen_string_literal: true
module
API
module
Entities
module
Ci
class
JobBasic
<
Grape
::
Entity
expose
:id
,
:status
,
:stage
,
:name
,
:ref
,
:tag
,
:coverage
,
:allow_failure
expose
:created_at
,
:started_at
,
:finished_at
expose
:duration
expose
:user
,
with:
::
API
::
Entities
::
User
expose
:commit
,
with:
::
API
::
Entities
::
Commit
expose
:pipeline
,
with:
::
API
::
Entities
::
Ci
::
PipelineBasic
expose
:web_url
do
|
job
,
_options
|
Gitlab
::
Routing
.
url_helpers
.
project_job_url
(
job
.
project
,
job
)
end
end
end
end
end
lib/api/entities/job_basic_with_project.rb
→
lib/api/entities/
ci/
job_basic_with_project.rb
View file @
df9f1676
...
...
@@ -2,8 +2,10 @@
module
API
module
Entities
class
JobBasicWithProject
<
Entities
::
JobBasic
module
Ci
class
JobBasicWithProject
<
Entities
::
Ci
::
JobBasic
expose
:project
,
with:
Entities
::
ProjectIdentity
end
end
end
end
lib/api/entities/ci/pipeline.rb
0 → 100644
View file @
df9f1676
# frozen_string_literal: true
module
API
module
Entities
module
Ci
class
Pipeline
<
PipelineBasic
expose
:before_sha
,
:tag
,
:yaml_errors
expose
:user
,
with:
Entities
::
UserBasic
expose
:created_at
,
:updated_at
,
:started_at
,
:finished_at
,
:committed_at
expose
:duration
expose
:coverage
expose
:detailed_status
,
using:
DetailedStatusEntity
do
|
pipeline
,
options
|
pipeline
.
detailed_status
(
options
[
:current_user
])
end
end
end
end
end
lib/api/entities/ci/pipeline_basic.rb
0 → 100644
View file @
df9f1676
# frozen_string_literal: true
module
API
module
Entities
module
Ci
class
PipelineBasic
<
Grape
::
Entity
expose
:id
,
:sha
,
:ref
,
:status
expose
:created_at
,
:updated_at
expose
:web_url
do
|
pipeline
,
_options
|
Gitlab
::
Routing
.
url_helpers
.
project_pipeline_url
(
pipeline
.
project
,
pipeline
)
end
end
end
end
end
lib/api/entities/ci/pipeline_schedule.rb
0 → 100644
View file @
df9f1676
# frozen_string_literal: true
module
API
module
Entities
module
Ci
class
PipelineSchedule
<
Grape
::
Entity
expose
:id
expose
:description
,
:ref
,
:cron
,
:cron_timezone
,
:next_run_at
,
:active
expose
:created_at
,
:updated_at
expose
:owner
,
using:
::
API
::
Entities
::
UserBasic
end
end
end
end
lib/api/entities/ci/pipeline_schedule_details.rb
0 → 100644
View file @
df9f1676
# frozen_string_literal: true
module
API
module
Entities
module
Ci
class
PipelineScheduleDetails
<
PipelineSchedule
expose
:last_pipeline
,
using:
::
API
::
Entities
::
Ci
::
PipelineBasic
expose
:variables
,
using:
::
API
::
Entities
::
Ci
::
Variable
end
end
end
end
lib/api/entities/ci/variable.rb
0 → 100644
View file @
df9f1676
# frozen_string_literal: true
module
API
module
Entities
module
Ci
class
Variable
<
Grape
::
Entity
expose
:variable_type
,
:key
,
:value
expose
:protected?
,
as: :protected
,
if:
->
(
entity
,
_
)
{
entity
.
respond_to?
(
:protected?
)
}
expose
:masked?
,
as: :masked
,
if:
->
(
entity
,
_
)
{
entity
.
respond_to?
(
:masked?
)
}
expose
:environment_scope
,
if:
->
(
entity
,
_
)
{
entity
.
respond_to?
(
:environment_scope
)
}
end
end
end
end
lib/api/entities/commit_detail.rb
View file @
df9f1676
...
...
@@ -9,7 +9,7 @@ module API
expose
:last_pipeline
do
|
commit
,
options
|
pipeline
=
commit
.
last_pipeline
if
can_read_pipeline?
::
API
::
Entities
::
PipelineBasic
.
represent
(
pipeline
,
options
)
::
API
::
Entities
::
Ci
::
PipelineBasic
.
represent
(
pipeline
,
options
)
end
private
...
...
lib/api/entities/deployment.rb
View file @
df9f1676
...
...
@@ -6,7 +6,7 @@ module API
expose
:id
,
:iid
,
:ref
,
:sha
,
:created_at
,
:updated_at
expose
:user
,
using:
Entities
::
UserBasic
expose
:environment
,
using:
Entities
::
EnvironmentBasic
expose
:deployable
,
using:
Entities
::
Job
expose
:deployable
,
using:
Entities
::
Ci
::
Job
expose
:status
end
end
...
...
lib/api/entities/job.rb
deleted
100644 → 0
View file @
19240517
# frozen_string_literal: true
module
API
module
Entities
class
Job
<
Entities
::
JobBasic
# artifacts_file is included in job_artifacts, but kept for backward compatibility (remove in api/v5)
expose
:artifacts_file
,
using:
Entities
::
JobArtifactFile
,
if:
->
(
job
,
opts
)
{
job
.
artifacts?
}
expose
:job_artifacts
,
as: :artifacts
,
using:
Entities
::
JobArtifact
expose
:runner
,
with:
Entities
::
Runner
expose
:artifacts_expire_at
end
end
end
lib/api/entities/job_basic.rb
deleted
100644 → 0
View file @
19240517
# frozen_string_literal: true
module
API
module
Entities
class
JobBasic
<
Grape
::
Entity
expose
:id
,
:status
,
:stage
,
:name
,
:ref
,
:tag
,
:coverage
,
:allow_failure
expose
:created_at
,
:started_at
,
:finished_at
expose
:duration
expose
:user
,
with:
Entities
::
User
expose
:commit
,
with:
Entities
::
Commit
expose
:pipeline
,
with:
Entities
::
PipelineBasic
expose
:web_url
do
|
job
,
_options
|
Gitlab
::
Routing
.
url_helpers
.
project_job_url
(
job
.
project
,
job
)
end
end
end
end
lib/api/entities/job_request/dependency.rb
View file @
df9f1676
...
...
@@ -5,7 +5,7 @@ module API
module
JobRequest
class
Dependency
<
Grape
::
Entity
expose
:id
,
:name
,
:token
expose
:artifacts_file
,
using:
Entities
::
JobArtifactFile
,
if:
->
(
job
,
_
)
{
job
.
artifacts?
}
expose
:artifacts_file
,
using:
Entities
::
Ci
::
JobArtifactFile
,
if:
->
(
job
,
_
)
{
job
.
artifacts?
}
end
end
end
...
...
lib/api/entities/merge_request.rb
View file @
df9f1676
...
...
@@ -23,11 +23,11 @@ module API
merge_request
.
metrics
&
.
first_deployed_to_production_at
end
expose
:pipeline
,
using:
Entities
::
PipelineBasic
,
if:
->
(
_
,
options
)
{
build_available?
(
options
)
}
do
|
merge_request
,
_options
|
expose
:pipeline
,
using:
Entities
::
Ci
::
PipelineBasic
,
if:
->
(
_
,
options
)
{
build_available?
(
options
)
}
do
|
merge_request
,
_options
|
merge_request
.
metrics
&
.
pipeline
end
expose
:head_pipeline
,
using:
'
API::Entities
::Pipeline'
,
if:
->
(
_
,
options
)
do
expose
:head_pipeline
,
using:
'
::API::Entities::Ci
::Pipeline'
,
if:
->
(
_
,
options
)
do
Ability
.
allowed?
(
options
[
:current_user
],
:read_pipeline
,
options
[
:project
])
end
...
...
lib/api/entities/package/pipeline.rb
View file @
df9f1676
...
...
@@ -3,7 +3,7 @@
module
API
module
Entities
class
Package
<
Grape
::
Entity
class
Pipeline
<
::
API
::
Entities
::
PipelineBasic
class
Pipeline
<
::
API
::
Entities
::
Ci
::
PipelineBasic
expose
:user
,
using:
::
API
::
Entities
::
UserBasic
end
end
...
...
lib/api/entities/pipeline.rb
deleted
100644 → 0
View file @
19240517
# frozen_string_literal: true
module
API
module
Entities
class
Pipeline
<
Entities
::
PipelineBasic
expose
:before_sha
,
:tag
,
:yaml_errors
expose
:user
,
with:
Entities
::
UserBasic
expose
:created_at
,
:updated_at
,
:started_at
,
:finished_at
,
:committed_at
expose
:duration
expose
:coverage
expose
:detailed_status
,
using:
DetailedStatusEntity
do
|
pipeline
,
options
|
pipeline
.
detailed_status
(
options
[
:current_user
])
end
end
end
end
lib/api/entities/pipeline_basic.rb
deleted
100644 → 0
View file @
19240517
# frozen_string_literal: true
module
API
module
Entities
class
PipelineBasic
<
Grape
::
Entity
expose
:id
,
:sha
,
:ref
,
:status
expose
:created_at
,
:updated_at
expose
:web_url
do
|
pipeline
,
_options
|
Gitlab
::
Routing
.
url_helpers
.
project_pipeline_url
(
pipeline
.
project
,
pipeline
)
end
end
end
end
lib/api/entities/pipeline_schedule.rb
deleted
100644 → 0
View file @
19240517
# frozen_string_literal: true
module
API
module
Entities
class
PipelineSchedule
<
Grape
::
Entity
expose
:id
expose
:description
,
:ref
,
:cron
,
:cron_timezone
,
:next_run_at
,
:active
expose
:created_at
,
:updated_at
expose
:owner
,
using:
Entities
::
UserBasic
end
end
end
lib/api/entities/pipeline_schedule_details.rb
deleted
100644 → 0
View file @
19240517
# frozen_string_literal: true
module
API
module
Entities
class
PipelineScheduleDetails
<
Entities
::
PipelineSchedule
expose
:last_pipeline
,
using:
Entities
::
PipelineBasic
expose
:variables
,
using:
Entities
::
Variable
end
end
end
lib/api/entities/variable.rb
deleted
100644 → 0
View file @
19240517
# frozen_string_literal: true
module
API
module
Entities
class
Variable
<
Grape
::
Entity
expose
:variable_type
,
:key
,
:value
expose
:protected?
,
as: :protected
,
if:
->
(
entity
,
_
)
{
entity
.
respond_to?
(
:protected?
)
}
expose
:masked?
,
as: :masked
,
if:
->
(
entity
,
_
)
{
entity
.
respond_to?
(
:masked?
)
}
expose
:environment_scope
,
if:
->
(
entity
,
_
)
{
entity
.
respond_to?
(
:environment_scope
)
}
end
end
end
lib/api/group_variables.rb
View file @
df9f1676
...
...
@@ -13,18 +13,18 @@ module API
resource
:groups
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
desc
'Get group-level variables'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
use
:pagination
end
get
':id/variables'
do
variables
=
user_group
.
variables
present
paginate
(
variables
),
with:
Entities
::
Variable
present
paginate
(
variables
),
with:
Entities
::
Ci
::
Variable
end
desc
'Get a specific variable from a group'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
@@ -36,12 +36,12 @@ module API
break
not_found!
(
'GroupVariable'
)
unless
variable
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Create a new variable in a group'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
@@ -58,14 +58,14 @@ module API
).
execute
if
variable
.
valid?
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
else
render_validation_error!
(
variable
)
end
end
desc
'Update an existing variable from a group'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
optional
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
@@ -83,7 +83,7 @@ module API
).
execute
if
variable
.
valid?
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
else
render_validation_error!
(
variable
)
end
...
...
@@ -93,7 +93,7 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
desc
'Delete an existing variable from a group'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
lib/api/job_artifacts.rb
View file @
df9f1676
...
...
@@ -94,7 +94,7 @@ module API
end
desc
'Keep the artifacts to prevent them from being deleted'
do
success
Entities
::
Job
success
::
API
::
Entities
::
Ci
::
Job
end
params
do
requires
:job_id
,
type:
Integer
,
desc:
'The ID of a job'
...
...
@@ -109,7 +109,7 @@ module API
build
.
keep_artifacts!
status
200
present
build
,
with:
Entities
::
Job
present
build
,
with:
::
API
::
Entities
::
Ci
::
Job
end
desc
'Delete the artifacts files from a job'
do
...
...
lib/api/jobs.rb
View file @
df9f1676
...
...
@@ -30,7 +30,7 @@ module API
end
desc
'Get a projects jobs'
do
success
Entities
::
Job
success
Entities
::
Ci
::
Job
end
params
do
use
:optional_scope
...
...
@@ -44,12 +44,12 @@ module API
builds
=
filter_builds
(
builds
,
params
[
:scope
])
builds
=
builds
.
preload
(
:user
,
:job_artifacts_archive
,
:job_artifacts
,
:runner
,
pipeline: :project
)
present
paginate
(
builds
),
with:
Entities
::
Job
present
paginate
(
builds
),
with:
Entities
::
Ci
::
Job
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Get pipeline jobs'
do
success
Entities
::
Job
success
Entities
::
Ci
::
Job
end
params
do
requires
:pipeline_id
,
type:
Integer
,
desc:
'The pipeline ID'
...
...
@@ -66,12 +66,12 @@ module API
builds
=
filter_builds
(
builds
,
params
[
:scope
])
builds
=
builds
.
preload
(
:job_artifacts_archive
,
:job_artifacts
,
project:
[
:namespace
])
present
paginate
(
builds
),
with:
Entities
::
Job
present
paginate
(
builds
),
with:
Entities
::
Ci
::
Job
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Get pipeline bridge jobs'
do
success
Entities
::
Bridge
success
::
API
::
Entities
::
Ci
::
Bridge
end
params
do
requires
:pipeline_id
,
type:
Integer
,
desc:
'The pipeline ID'
...
...
@@ -92,12 +92,12 @@ module API
project:
[
:namespace
]
)
present
paginate
(
bridges
),
with:
Entities
::
Bridge
present
paginate
(
bridges
),
with:
::
API
::
Entities
::
Ci
::
Bridge
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Get a specific job of a project'
do
success
Entities
::
Job
success
Entities
::
Ci
::
Job
end
params
do
requires
:job_id
,
type:
Integer
,
desc:
'The ID of a job'
...
...
@@ -107,7 +107,7 @@ module API
build
=
find_build!
(
params
[
:job_id
])
present
build
,
with:
Entities
::
Job
present
build
,
with:
Entities
::
Ci
::
Job
end
# TODO: We should use `present_disk_file!` and leave this implementation for backward compatibility (when build trace
...
...
@@ -131,7 +131,7 @@ module API
end
desc
'Cancel a specific job of a project'
do
success
Entities
::
Job
success
Entities
::
Ci
::
Job
end
params
do
requires
:job_id
,
type:
Integer
,
desc:
'The ID of a job'
...
...
@@ -144,11 +144,11 @@ module API
build
.
cancel
present
build
,
with:
Entities
::
Job
present
build
,
with:
Entities
::
Ci
::
Job
end
desc
'Retry a specific build of a project'
do
success
Entities
::
Job
success
Entities
::
Ci
::
Job
end
params
do
requires
:job_id
,
type:
Integer
,
desc:
'The ID of a build'
...
...
@@ -162,11 +162,11 @@ module API
build
=
::
Ci
::
Build
.
retry
(
build
,
current_user
)
present
build
,
with:
Entities
::
Job
present
build
,
with:
Entities
::
Ci
::
Job
end
desc
'Erase job (remove artifacts and the trace)'
do
success
Entities
::
Job
success
Entities
::
Ci
::
Job
end
params
do
requires
:job_id
,
type:
Integer
,
desc:
'The ID of a build'
...
...
@@ -179,11 +179,11 @@ module API
break
forbidden!
(
'Job is not erasable!'
)
unless
build
.
erasable?
build
.
erase
(
erased_by:
current_user
)
present
build
,
with:
Entities
::
Job
present
build
,
with:
Entities
::
Ci
::
Job
end
desc
'Trigger a actionable job (manual, delayed, etc)'
do
success
Entities
::
Job
success
Entities
::
Ci
::
Job
detail
'This feature was added in GitLab 8.11'
end
params
do
...
...
@@ -200,7 +200,7 @@ module API
build
.
play
(
current_user
)
status
200
present
build
,
with:
Entities
::
Job
present
build
,
with:
Entities
::
Ci
::
Job
end
end
...
...
lib/api/merge_requests.rb
View file @
df9f1676
...
...
@@ -352,16 +352,16 @@ module API
end
desc
'Get the merge request pipelines'
do
success
Entities
::
PipelineBasic
success
Entities
::
Ci
::
PipelineBasic
end
get
':id/merge_requests/:merge_request_iid/pipelines'
do
pipelines
=
merge_request_pipelines_with_access
present
paginate
(
pipelines
),
with:
Entities
::
PipelineBasic
present
paginate
(
pipelines
),
with:
Entities
::
Ci
::
PipelineBasic
end
desc
'Create a pipeline for merge request'
do
success
Entities
::
Pipeline
success
::
API
::
Entities
::
Ci
::
Pipeline
end
post
':id/merge_requests/:merge_request_iid/pipelines'
do
pipeline
=
::
MergeRequests
::
CreatePipelineService
...
...
@@ -372,7 +372,7 @@ module API
not_allowed!
elsif
pipeline
.
persisted?
status
:ok
present
pipeline
,
with:
Entities
::
Pipeline
present
pipeline
,
with:
::
API
::
Entities
::
Ci
::
Pipeline
else
render_validation_error!
(
pipeline
)
end
...
...
lib/api/triggers.rb
View file @
df9f1676
...
...
@@ -11,7 +11,7 @@ module API
end
resource
:projects
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
desc
'Trigger a GitLab project pipeline'
do
success
Entities
::
Pipeline
success
Entities
::
Ci
::
Pipeline
end
params
do
requires
:ref
,
type:
String
,
desc:
'The commit sha or name of a branch or tag'
,
allow_blank:
false
...
...
@@ -38,7 +38,7 @@ module API
if
result
[
:http_status
]
render_api_error!
(
result
[
:message
],
result
[
:http_status
])
else
present
result
[
:pipeline
],
with:
Entities
::
Pipeline
present
result
[
:pipeline
],
with:
Entities
::
Ci
::
Pipeline
end
end
...
...
lib/api/variables.rb
View file @
df9f1676
...
...
@@ -30,18 +30,18 @@ module API
resource
:projects
,
requirements:
API
::
NAMESPACE_OR_PROJECT_REQUIREMENTS
do
desc
'Get project variables'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
use
:pagination
end
get
':id/variables'
do
variables
=
user_project
.
variables
present
paginate
(
variables
),
with:
Entities
::
Variable
present
paginate
(
variables
),
with:
Entities
::
Ci
::
Variable
end
desc
'Get a specific variable from a project'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
@@ -51,12 +51,12 @@ module API
variable
=
find_variable
(
params
)
not_found!
(
'Variable'
)
unless
variable
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Create a new variable in a project'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
@@ -73,14 +73,14 @@ module API
variable
=
user_project
.
variables
.
create
(
variable_params
)
if
variable
.
valid?
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
else
render_validation_error!
(
variable
)
end
end
desc
'Update an existing variable from a project'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
optional
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
@@ -100,7 +100,7 @@ module API
variable_params
=
filter_variable_parameters
(
variable_params
)
if
variable
.
update
(
variable_params
)
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Ci
::
Variable
else
render_validation_error!
(
variable
)
end
...
...
@@ -108,7 +108,7 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
desc
'Delete an existing variable from a project'
do
success
Entities
::
Variable
success
Entities
::
Ci
::
Variable
end
params
do
requires
:key
,
type:
String
,
desc:
'The key of the variable'
...
...
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