gitlab-org--gitlab-foss/lib/api/version.rb

33 lines
716 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-10-12 07:32:48 -04:00
module API
class Version < Grape::API::Instance
helpers ::API::Helpers::GraphqlHelpers
include APIGuard
allow_access_with_scope :read_user, if: -> (request) { request.get? }
2016-10-12 07:32:48 -04:00
before { authenticate! }
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
run_graphql!(
query: METADATA_QUERY,
context: { current_user: current_user },
transform: ->(result) { result.dig('data', 'metadata') }
)
2016-10-12 07:32:48 -04:00
end
end
end