Commit 2e110b2f authored by Stan Hu's avatar Stan Hu

Merge branch 'refactoring-entities-file-23' into 'master'

Separate environment entities in class files

See merge request gitlab-org/gitlab!24951
parents 417747c9 b4e16cda
---
title: Separate environment entities into own class files
merge_request: 24951
author: Rajendra Kadam
type: added
......@@ -170,39 +170,6 @@ module API
expose :variables, using: Entities::Variable
end
class EnvironmentBasic < Grape::Entity
expose :id, :name, :slug, :external_url
end
class Deployment < Grape::Entity
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 :status
end
class Environment < EnvironmentBasic
expose :project, using: Entities::BasicProjectDetails
expose :last_deployment, using: Entities::Deployment, if: { last_deployment: true }
expose :state
end
class LicenseBasic < Grape::Entity
expose :key, :name, :nickname
expose :url, as: :html_url
expose(:source_url) { |license| license.meta['source'] }
end
class License < LicenseBasic
expose :popular?, as: :popular
expose(:description) { |license| license.meta['description'] }
expose(:conditions) { |license| license.meta['conditions'] }
expose(:permissions) { |license| license.meta['permissions'] }
expose(:limitations) { |license| license.meta['limitations'] }
expose :content
end
class ImpersonationToken < PersonalAccessToken
expose :impersonation
end
......
# frozen_string_literal: true
module API
module Entities
class Deployment < Grape::Entity
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 :status
end
end
end
# frozen_string_literal: true
module API
module Entities
class Environment < Entities::EnvironmentBasic
expose :project, using: Entities::BasicProjectDetails
expose :last_deployment, using: Entities::Deployment, if: { last_deployment: true }
expose :state
end
end
end
# frozen_string_literal: true
module API
module Entities
class EnvironmentBasic < Grape::Entity
expose :id, :name, :slug, :external_url
end
end
end
# frozen_string_literal: true
module API
module Entities
class License < Entities::LicenseBasic
expose :popular?, as: :popular
expose(:description) { |license| license.meta['description'] }
expose(:conditions) { |license| license.meta['conditions'] }
expose(:permissions) { |license| license.meta['permissions'] }
expose(:limitations) { |license| license.meta['limitations'] }
expose :content
end
end
end
# frozen_string_literal: true
module API
module Entities
class LicenseBasic < Grape::Entity
expose :key, :name, :nickname
expose :url, as: :html_url
expose(:source_url) { |license| license.meta['source'] }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment