2018-09-29 18:34:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-12 07:32:48 -04:00
|
|
|
module API
|
2020-10-14 20:08:42 -04:00
|
|
|
class Version < ::API::Base
|
2019-01-24 11:23:57 -05:00
|
|
|
helpers ::API::Helpers::GraphqlHelpers
|
2020-02-24 16:09:08 -05:00
|
|
|
include APIGuard
|
|
|
|
|
2021-02-02 13:09:42 -05:00
|
|
|
allow_access_with_scope :read_user, if: -> (request) { request.get? || request.head? }
|
2019-01-24 11:23:57 -05:00
|
|
|
|
2016-10-12 07:32:48 -04:00
|
|
|
before { authenticate! }
|
|
|
|
|
2022-04-05 08:10:23 -04:00
|
|
|
feature_category :not_owned # rubocop:todo Gitlab/AvoidFeatureCategoryNotOwned
|
2020-10-30 14:08:56 -04:00
|
|
|
|
2019-01-24 11:23:57 -05:00
|
|
|
METADATA_QUERY = <<~EOF
|
|
|
|
{
|
|
|
|
metadata {
|
|
|
|
version
|
|
|
|
revision
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2016-10-12 07:32:48 -04:00
|
|
|
desc 'Get the version information of the GitLab instance.' do
|
|
|
|
detail 'This feature was introduced in GitLab 8.13.'
|
|
|
|
end
|
|
|
|
get '/version' do
|
2019-10-01 08:05:59 -04:00
|
|
|
run_graphql!(
|
2019-01-24 11:23:57 -05:00
|
|
|
query: METADATA_QUERY,
|
|
|
|
context: { current_user: current_user },
|
2019-10-01 08:05:59 -04:00
|
|
|
transform: ->(result) { result.dig('data', 'metadata') }
|
2019-01-24 11:23:57 -05:00
|
|
|
)
|
2016-10-12 07:32:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|