diff options
Diffstat (limited to 'lib/api/entities')
-rw-r--r-- | lib/api/entities/batched_background_migration.rb | 14 | ||||
-rw-r--r-- | lib/api/entities/ci/job_basic.rb | 6 | ||||
-rw-r--r-- | lib/api/entities/ci/job_request/image.rb | 2 | ||||
-rw-r--r-- | lib/api/entities/ci/job_request/service.rb | 2 | ||||
-rw-r--r-- | lib/api/entities/merge_request_reviewer.rb | 1 | ||||
-rw-r--r-- | lib/api/entities/ml/mlflow/experiment.rb | 28 | ||||
-rw-r--r-- | lib/api/entities/ml/mlflow/new_experiment.rb | 19 | ||||
-rw-r--r-- | lib/api/entities/ml/mlflow/run.rb | 16 | ||||
-rw-r--r-- | lib/api/entities/ml/mlflow/run_info.rb | 27 | ||||
-rw-r--r-- | lib/api/entities/ml/mlflow/update_run.rb | 19 | ||||
-rw-r--r-- | lib/api/entities/package.rb | 1 | ||||
-rw-r--r-- | lib/api/entities/personal_access_token_with_details.rb | 13 | ||||
-rw-r--r-- | lib/api/entities/user_safe.rb | 6 |
13 files changed, 137 insertions, 17 deletions
diff --git a/lib/api/entities/batched_background_migration.rb b/lib/api/entities/batched_background_migration.rb new file mode 100644 index 00000000000..eba17ff98f4 --- /dev/null +++ b/lib/api/entities/batched_background_migration.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module API + module Entities + class BatchedBackgroundMigration < Grape::Entity + expose :id + expose :job_class_name + expose :table_name + expose :status, &:status_name + expose :progress + expose :created_at + end + end +end diff --git a/lib/api/entities/ci/job_basic.rb b/lib/api/entities/ci/job_basic.rb index 0badde4089e..3d9318ec428 100644 --- a/lib/api/entities/ci/job_basic.rb +++ b/lib/api/entities/ci/job_basic.rb @@ -18,6 +18,12 @@ module API expose :web_url do |job, _options| Gitlab::Routing.url_helpers.project_job_url(job.project, job) end + + expose :project do + expose :ci_job_token_scope_enabled do |job| + job.project.ci_job_token_scope_enabled? + end + end end end end diff --git a/lib/api/entities/ci/job_request/image.rb b/lib/api/entities/ci/job_request/image.rb index 83f64da6050..92d68269265 100644 --- a/lib/api/entities/ci/job_request/image.rb +++ b/lib/api/entities/ci/job_request/image.rb @@ -8,7 +8,7 @@ module API expose :name, :entrypoint expose :ports, using: Entities::Ci::JobRequest::Port - expose :pull_policy, if: ->(_) { ::Feature.enabled?(:ci_docker_image_pull_policy) } + expose :pull_policy end end end diff --git a/lib/api/entities/ci/job_request/service.rb b/lib/api/entities/ci/job_request/service.rb index 7d494c7e516..128591058fe 100644 --- a/lib/api/entities/ci/job_request/service.rb +++ b/lib/api/entities/ci/job_request/service.rb @@ -8,7 +8,7 @@ module API expose :name, :entrypoint expose :ports, using: Entities::Ci::JobRequest::Port - expose :pull_policy, if: ->(_) { ::Feature.enabled?(:ci_docker_image_pull_policy) } + expose :pull_policy expose :alias, :command expose :variables end diff --git a/lib/api/entities/merge_request_reviewer.rb b/lib/api/entities/merge_request_reviewer.rb index 3bf2ccc36aa..a47321ef929 100644 --- a/lib/api/entities/merge_request_reviewer.rb +++ b/lib/api/entities/merge_request_reviewer.rb @@ -4,7 +4,6 @@ module API module Entities class MergeRequestReviewer < Grape::Entity expose :reviewer, as: :user, using: Entities::UserBasic - expose :updated_state_by, using: Entities::UserBasic expose :state expose :created_at end diff --git a/lib/api/entities/ml/mlflow/experiment.rb b/lib/api/entities/ml/mlflow/experiment.rb new file mode 100644 index 00000000000..cfe366feaab --- /dev/null +++ b/lib/api/entities/ml/mlflow/experiment.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module API + module Entities + module Ml + module Mlflow + class Experiment < Grape::Entity + expose :experiment do + expose :experiment_id + expose :name + expose :lifecycle_stage + expose :artifact_location + end + + private + + def lifecycle_stage + object.deleted_on? ? 'deleted' : 'active' + end + + def experiment_id + object.iid.to_s + end + end + end + end + end +end diff --git a/lib/api/entities/ml/mlflow/new_experiment.rb b/lib/api/entities/ml/mlflow/new_experiment.rb new file mode 100644 index 00000000000..09791839850 --- /dev/null +++ b/lib/api/entities/ml/mlflow/new_experiment.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module API + module Entities + module Ml + module Mlflow + class NewExperiment < Grape::Entity + expose :experiment_id + + private + + def experiment_id + object.iid.to_s + end + end + end + end + end +end diff --git a/lib/api/entities/ml/mlflow/run.rb b/lib/api/entities/ml/mlflow/run.rb new file mode 100644 index 00000000000..c679330206e --- /dev/null +++ b/lib/api/entities/ml/mlflow/run.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module API + module Entities + module Ml + module Mlflow + class Run < Grape::Entity + expose :run do + expose(:info) { |candidate| RunInfo.represent(candidate) } + expose(:data) { |candidate| {} } + end + end + end + end + end +end diff --git a/lib/api/entities/ml/mlflow/run_info.rb b/lib/api/entities/ml/mlflow/run_info.rb new file mode 100644 index 00000000000..096950e349d --- /dev/null +++ b/lib/api/entities/ml/mlflow/run_info.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module API + module Entities + module Ml + module Mlflow + class RunInfo < Grape::Entity + expose :run_id + expose :run_id, as: :run_uuid + expose(:experiment_id) { |candidate| candidate.experiment.iid.to_s } + expose(:start_time) { |candidate| candidate.start_time || 0 } + expose :end_time, expose_nil: false + expose(:status) { |candidate| candidate.status.to_s.upcase } + expose(:artifact_uri) { |candidate| 'not_implemented' } + expose(:lifecycle_stage) { |candidate| 'active' } + expose(:user_id) { |candidate| candidate.user_id.to_s } + + private + + def run_id + object.iid.to_s + end + end + end + end + end +end diff --git a/lib/api/entities/ml/mlflow/update_run.rb b/lib/api/entities/ml/mlflow/update_run.rb new file mode 100644 index 00000000000..5acdaab0e33 --- /dev/null +++ b/lib/api/entities/ml/mlflow/update_run.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module API + module Entities + module Ml + module Mlflow + class UpdateRun < Grape::Entity + expose :run_info + + private + + def run_info + ::API::Entities::Ml::Mlflow::RunInfo.represent object + end + end + end + end + end +end diff --git a/lib/api/entities/package.rb b/lib/api/entities/package.rb index 1efd457aa5f..18fc0576dd4 100644 --- a/lib/api/entities/package.rb +++ b/lib/api/entities/package.rb @@ -39,6 +39,7 @@ module API end expose :created_at + expose :last_downloaded_at expose :project_id, if: ->(_, opts) { opts[:group] } expose :project_path, if: ->(obj, opts) { opts[:group] && Ability.allowed?(opts[:user], :read_project, obj.project) } expose :tags diff --git a/lib/api/entities/personal_access_token_with_details.rb b/lib/api/entities/personal_access_token_with_details.rb deleted file mode 100644 index 5654bd4a1e1..00000000000 --- a/lib/api/entities/personal_access_token_with_details.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module API - module Entities - class PersonalAccessTokenWithDetails < Entities::PersonalAccessToken - expose :expired?, as: :expired - expose :expires_soon?, as: :expires_soon - expose :revoke_path do |token| - Gitlab::Routing.url_helpers.revoke_profile_personal_access_token_path(token) - end - end - end -end diff --git a/lib/api/entities/user_safe.rb b/lib/api/entities/user_safe.rb index fb99c2e960d..127a8ef2160 100644 --- a/lib/api/entities/user_safe.rb +++ b/lib/api/entities/user_safe.rb @@ -3,9 +3,13 @@ module API module Entities class UserSafe < Grape::Entity + include RequestAwareEntity + expose :id, :username expose :name do |user| - user.redacted_name(options[:current_user]) + current_user = request.respond_to?(:current_user) ? request.current_user : options.fetch(:current_user, nil) + + user.redacted_name(current_user) end end end |