From 29a3203b3fe08649b80def65b7750a866454d3d6 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 10 May 2017 15:26:17 +1100 Subject: Use relative paths for group/project/user avatars --- lib/api/entities.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index f8f5548d23d..00d494f02f5 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -5,7 +5,10 @@ module API end class UserBasic < UserSafe - expose :id, :state, :avatar_url + expose :id, :state + expose :avatar_url do |user, options| + user.avatar_url(only_path: false) + end expose :web_url do |user, options| Gitlab::Routing.url_helpers.user_url(user) @@ -97,7 +100,9 @@ module API expose :creator_id expose :namespace, using: 'API::Entities::Namespace' expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? } - expose :avatar_url + expose :avatar_url do |user, options| + user.avatar_url(only_path: false) + end expose :star_count, :forks_count expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? } expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] } @@ -141,7 +146,9 @@ module API class Group < Grape::Entity expose :id, :name, :path, :description, :visibility expose :lfs_enabled?, as: :lfs_enabled - expose :avatar_url + expose :avatar_url do |user, options| + user.avatar_url(only_path: false) + end expose :web_url expose :request_access_enabled expose :full_name, :full_path -- cgit v1.2.1 From cfb4404ef6464ed4780bc7619268287716ae5e73 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Fri, 5 May 2017 18:00:32 +0200 Subject: Update SystemHooks API to expose and handle new repository_update_events --- lib/api/entities.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 00d494f02f5..3fc2b453eb6 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -53,7 +53,7 @@ module API end class Hook < Grape::Entity - expose :id, :url, :created_at, :push_events, :tag_push_events + expose :id, :url, :created_at, :push_events, :tag_push_events, :repository_update_events expose :enable_ssl_verification end -- cgit v1.2.1 From cac7e03fa1cb39a685bcde87d4d67fb17c4f48f2 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Thu, 11 May 2017 11:41:36 +0200 Subject: Rename `build_events` to `job_events` in code --- lib/api/entities.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 3fc2b453eb6..01cc8e8e1ca 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -60,7 +60,7 @@ module API class ProjectHook < Hook expose :project_id, :issues_events, :merge_requests_events expose :note_events, :pipeline_events, :wiki_page_events - expose :build_events, as: :job_events + expose :job_events end class BasicProjectDetails < Grape::Entity @@ -470,7 +470,7 @@ module API expose :id, :title, :created_at, :updated_at, :active expose :push_events, :issues_events, :merge_requests_events expose :tag_push_events, :note_events, :pipeline_events - expose :build_events, as: :job_events + expose :job_events # Expose serialized properties expose :properties do |service, options| field_names = service.fields. -- cgit v1.2.1 From 950fa32a7c2c25d70bf8b2d495d759ce40bf2d9b Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 15 May 2017 20:24:19 +0000 Subject: Revert "Merge branch 'bvl-rename-build-events-to-job-events' into 'master'" This reverts merge request !11287 --- lib/api/entities.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 01cc8e8e1ca..3fc2b453eb6 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -60,7 +60,7 @@ module API class ProjectHook < Hook expose :project_id, :issues_events, :merge_requests_events expose :note_events, :pipeline_events, :wiki_page_events - expose :job_events + expose :build_events, as: :job_events end class BasicProjectDetails < Grape::Entity @@ -470,7 +470,7 @@ module API expose :id, :title, :created_at, :updated_at, :active expose :push_events, :issues_events, :merge_requests_events expose :tag_push_events, :note_events, :pipeline_events - expose :job_events + expose :build_events, as: :job_events # Expose serialized properties expose :properties do |service, options| field_names = service.fields. -- cgit v1.2.1 From 1fd83f972cf5ce73b3e46fd2df5ffb07889b1fd1 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 15 May 2017 15:11:45 +0000 Subject: Merge branch 'bvl-rename-build-events-to-job-events' into 'master' Rename `build_events` to `job_events` Closes #31620 See merge request !11287 --- lib/api/entities.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 3fc2b453eb6..01cc8e8e1ca 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -60,7 +60,7 @@ module API class ProjectHook < Hook expose :project_id, :issues_events, :merge_requests_events expose :note_events, :pipeline_events, :wiki_page_events - expose :build_events, as: :job_events + expose :job_events end class BasicProjectDetails < Grape::Entity @@ -470,7 +470,7 @@ module API expose :id, :title, :created_at, :updated_at, :active expose :push_events, :issues_events, :merge_requests_events expose :tag_push_events, :note_events, :pipeline_events - expose :build_events, as: :job_events + expose :job_events # Expose serialized properties expose :properties do |service, options| field_names = service.fields. -- cgit v1.2.1 From 34974258bc3f745c86512319231bad47232fe007 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 3 May 2017 14:49:37 +0200 Subject: Hide nested group UI/API support for MySQL This hides/disables some UI elements and API parameters related to nested groups when MySQL is used, since nested groups are not supported for MySQL. --- lib/api/entities.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 3fc2b453eb6..e3692a58119 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -152,7 +152,10 @@ module API expose :web_url expose :request_access_enabled expose :full_name, :full_path - expose :parent_id + + if ::Group.supports_nested_groups? + expose :parent_id + end expose :statistics, if: :statistics do with_options format_with: -> (value) { value.to_i } do -- cgit v1.2.1 From d9a0188d2f7dfc07b426d36eeebc2c94385c12ca Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 15 May 2017 12:10:29 -0500 Subject: Add question mark to Gitlab::Diff::File predicate methods --- lib/api/entities.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 01cc8e8e1ca..cf4affe1758 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -252,7 +252,9 @@ module API class RepoDiff < Grape::Entity expose :old_path, :new_path, :a_mode, :b_mode, :diff - expose :new_file, :renamed_file, :deleted_file + expose :new_file?, as: :new_file + expose :renamed_file?, as: :renamed_file + expose :deleted_file?, as: :deleted_file end class Milestone < ProjectEntity -- cgit v1.2.1 From bd66bf08b5b9a2cea9320100a91240e93f1c06e5 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 25 May 2017 19:49:46 +0800 Subject: API and doc for protected variables --- lib/api/entities.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 01cc8e8e1ca..b5308aeecf6 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -670,6 +670,7 @@ module API class Variable < Grape::Entity expose :key, :value + expose :protected?, as: :protected end class Pipeline < PipelineBasic -- cgit v1.2.1 From aed0387f97ec62b184da90bdca0ce40f9dc58b45 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 26 May 2017 18:27:30 -0500 Subject: Consistent diff and blob size limit names --- lib/api/entities.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8c5e5c91769..9799fe68a76 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -331,7 +331,7 @@ module API class MergeRequestChanges < MergeRequest expose :diffs, as: :changes, using: Entities::RepoDiff do |compare, _| - compare.raw_diffs(all_diffs: true).to_a + compare.raw_diffs(no_limits: true).to_a end end @@ -344,7 +344,7 @@ module API expose :commits, using: Entities::RepoCommit expose :diffs, using: Entities::RepoDiff do |compare, _| - compare.raw_diffs(all_diffs: true).to_a + compare.raw_diffs(no_limits: true).to_a end end @@ -548,7 +548,7 @@ module API end expose :diffs, using: Entities::RepoDiff do |compare, options| - compare.diffs(all_diffs: true).to_a + compare.diffs(no_limits: true).to_a end expose :compare_timeout do |compare, options| -- cgit v1.2.1 From fbd3b3d8a245072121784df11b7b41d3257b989f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 12 May 2017 04:12:04 +0900 Subject: Add API support for pipeline schedule --- lib/api/entities.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8c5e5c91769..1f1942b2ec1 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -686,6 +686,14 @@ module API expose :coverage end + class PipelineSchedule < Grape::Entity + expose :id + expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active + expose :created_at, :updated_at, :deleted_at + expose :last_pipeline, using: Entities::Pipeline, if: -> (pipeline_schedule, opts) { pipeline_schedule.last_pipeline.present? } + expose :owner, using: Entities::UserBasic + end + class EnvironmentBasic < Grape::Entity expose :id, :name, :slug, :external_url end -- cgit v1.2.1 From 97bf2401991ab2e9cea956dfb7c9630e2a185683 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sat, 13 May 2017 03:06:05 +0900 Subject: Remove if from last_pipeline in entity --- lib/api/entities.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 1f1942b2ec1..b2bc0a17142 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -690,7 +690,7 @@ module API expose :id expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active expose :created_at, :updated_at, :deleted_at - expose :last_pipeline, using: Entities::Pipeline, if: -> (pipeline_schedule, opts) { pipeline_schedule.last_pipeline.present? } + expose :last_pipeline, using: Entities::Pipeline expose :owner, using: Entities::UserBasic end -- cgit v1.2.1 From 94f7595b9a8edcb4ac8480995a067eb4fa3dec7e Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 17 May 2017 00:20:11 +0900 Subject: Define last_pipeline in PipelineScheduleEntity --- lib/api/entities.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index b2bc0a17142..93f28e39f82 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -690,7 +690,9 @@ module API expose :id expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active expose :created_at, :updated_at, :deleted_at - expose :last_pipeline, using: Entities::Pipeline + expose :last_pipeline, using: Entities::Pipeline do |pipeline_schedule| + pipeline_schedule.pipelines&.last + end expose :owner, using: Entities::UserBasic end -- cgit v1.2.1 From 17b9128b305aefc29fddae3b51d13c61ae7dfef9 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 17 May 2017 22:58:23 +0900 Subject: includes last_pipeline --- lib/api/entities.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 93f28e39f82..b2bc0a17142 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -690,9 +690,7 @@ module API expose :id expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active expose :created_at, :updated_at, :deleted_at - expose :last_pipeline, using: Entities::Pipeline do |pipeline_schedule| - pipeline_schedule.pipelines&.last - end + expose :last_pipeline, using: Entities::Pipeline expose :owner, using: Entities::UserBasic end -- cgit v1.2.1 From 20a07d26ff4be9c82271297e516df912109b05aa Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 18 May 2017 17:45:08 +0900 Subject: Include owner for pipeline_schedules. Improve N+1 spec. Use PipelineBasic for small payload. --- lib/api/entities.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index b2bc0a17142..f0260cf03f3 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -690,7 +690,7 @@ module API expose :id expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active expose :created_at, :updated_at, :deleted_at - expose :last_pipeline, using: Entities::Pipeline + expose :last_pipeline, using: Entities::PipelineBasic expose :owner, using: Entities::UserBasic end -- cgit v1.2.1 From f6a8894a5928e1cc37d8301c555fcfd5953cc180 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 19 May 2017 02:42:23 +0900 Subject: Expose last_pipeline only when detailed status --- lib/api/entities.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index f0260cf03f3..d779cd2a294 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -690,7 +690,7 @@ module API expose :id expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active expose :created_at, :updated_at, :deleted_at - expose :last_pipeline, using: Entities::PipelineBasic + expose :last_pipeline, using: Entities::PipelineBasic, if: { type: :full } expose :owner, using: Entities::UserBasic end -- cgit v1.2.1 From bfa028e13a41b16b0da2d69359694edbebf9e455 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 19 May 2017 22:24:31 +0900 Subject: Remove deleted_at from Entity. Use find_by. Remove returns. --- lib/api/entities.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index d779cd2a294..40ef62fdb14 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -689,7 +689,7 @@ module API class PipelineSchedule < Grape::Entity expose :id expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active - expose :created_at, :updated_at, :deleted_at + expose :created_at, :updated_at expose :last_pipeline, using: Entities::PipelineBasic, if: { type: :full } expose :owner, using: Entities::UserBasic end -- cgit v1.2.1 From b17c8d67d8811e0a440338dc25464d8c90e81179 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sat, 27 May 2017 21:29:01 +0900 Subject: Use PipelineScheduleDetails --- lib/api/entities.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 40ef62fdb14..e10bd230ae2 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -690,10 +690,13 @@ module API expose :id expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active expose :created_at, :updated_at - expose :last_pipeline, using: Entities::PipelineBasic, if: { type: :full } expose :owner, using: Entities::UserBasic end + class PipelineScheduleDetails < PipelineSchedule + expose :last_pipeline, using: Entities::PipelineBasic + end + class EnvironmentBasic < Grape::Entity expose :id, :name, :slug, :external_url end -- cgit v1.2.1 From 4464c22d6d23d893494682d309aec3fb31c11ae3 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Wed, 3 May 2017 17:26:49 +0200 Subject: Support descriptions for snippets --- lib/api/entities.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8c5e5c91769..22880066d84 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -224,7 +224,7 @@ module API end class ProjectSnippet < Grape::Entity - expose :id, :title, :file_name + expose :id, :title, :file_name, :description expose :author, using: Entities::UserBasic expose :updated_at, :created_at @@ -234,7 +234,7 @@ module API end class PersonalSnippet < Grape::Entity - expose :id, :title, :file_name + expose :id, :title, :file_name, :description expose :author, using: Entities::UserBasic expose :updated_at, :created_at -- cgit v1.2.1 From 04cf618b6ff943527938f64a451a420b494b5a76 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 31 May 2017 14:41:25 -0500 Subject: Change no_limits to limits --- lib/api/entities.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 9799fe68a76..5032bab77b7 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -331,7 +331,7 @@ module API class MergeRequestChanges < MergeRequest expose :diffs, as: :changes, using: Entities::RepoDiff do |compare, _| - compare.raw_diffs(no_limits: true).to_a + compare.raw_diffs(limits: false).to_a end end @@ -344,7 +344,7 @@ module API expose :commits, using: Entities::RepoCommit expose :diffs, using: Entities::RepoDiff do |compare, _| - compare.raw_diffs(no_limits: true).to_a + compare.raw_diffs(limits: false).to_a end end @@ -548,7 +548,7 @@ module API end expose :diffs, using: Entities::RepoDiff do |compare, options| - compare.diffs(no_limits: true).to_a + compare.diffs(limits: false).to_a end expose :compare_timeout do |compare, options| -- cgit v1.2.1 From 671284ba375109becbfa2a288032cdc7301b157b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Wed, 31 May 2017 21:06:01 +0000 Subject: Add feature toggles through Flipper --- lib/api/entities.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e10bd230ae2..fc8183a62c1 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -753,6 +753,28 @@ module API expose :impersonation end + class FeatureGate < Grape::Entity + expose :key + expose :value + end + + class Feature < Grape::Entity + expose :name + expose :state + expose :gates, using: FeatureGate do |model| + model.gates.map do |gate| + value = model.gate_values[gate.key] + + # By default all gate values are populated. Only show relevant ones. + if (value.is_a?(Integer) && value.zero?) || (value.is_a?(Set) && value.empty?) + next + end + + { key: gate.key, value: value } + end.compact + end + end + module JobRequest class JobInfo < Grape::Entity expose :name, :stage -- cgit v1.2.1 From c2516115e391360055f733d40af8aff2af52196b Mon Sep 17 00:00:00 2001 From: Robin Bobbitt Date: Thu, 1 Jun 2017 10:57:41 -0400 Subject: Expose import_status in Projects API --- lib/api/entities.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e3258fdcffe..ea18cd83a0b 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -100,6 +100,8 @@ module API expose :creator_id expose :namespace, using: 'API::Entities::Namespace' expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda{ |project, options| project.forked? } + expose :import_status + expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] } expose :avatar_url do |user, options| user.avatar_url(only_path: false) end -- cgit v1.2.1