X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/38e27663cf656f0c9c443a2715f249afe39a8bfb..44c95f99098fa6c6acbfa82d4b6cbc6015eb6e39:/services/api/app/controllers/arvados/v1/schema_controller.rb diff --git a/services/api/app/controllers/arvados/v1/schema_controller.rb b/services/api/app/controllers/arvados/v1/schema_controller.rb index bc5a20fb0d..d5ba487d0f 100644 --- a/services/api/app/controllers/arvados/v1/schema_controller.rb +++ b/services/api/app/controllers/arvados/v1/schema_controller.rb @@ -1,9 +1,20 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + class Arvados::V1::SchemaController < ApplicationController + skip_before_filter :catch_redirect_hint skip_before_filter :find_objects_for_index skip_before_filter :find_object_by_uuid + skip_before_filter :load_filters_param + skip_before_filter :load_limit_offset_order_params + skip_before_filter :load_read_auths + skip_before_filter :load_where_param skip_before_filter :render_404_if_no_object skip_before_filter :require_auth_scope + include DbCurrentTime + def index expires_in 24.hours, public: true discovery = Rails.cache.fetch 'arvados_v1_rest_discovery' do @@ -15,11 +26,12 @@ class Arvados::V1::SchemaController < ApplicationController name: "arvados", version: "v1", revision: "20131114", - source_version: (Rails.application.config.source_version ? Rails.application.config.source_version : "No version information available") + (Rails.application.config.local_modified ? Rails.application.config.local_modified.to_s : ''), - generatedAt: Time.now.iso8601, + source_version: AppVersion.hash, + generatedAt: db_current_time.iso8601, title: "Arvados API", description: "The API to interact with Arvados.", documentationLink: "http://doc.arvados.org/api/index.html", + defaultCollectionReplication: Rails.configuration.default_collection_replication, protocol: "rest", baseUrl: root_url + "arvados/v1/", basePath: "/arvados/v1/", @@ -27,6 +39,17 @@ class Arvados::V1::SchemaController < ApplicationController servicePath: "arvados/v1/", batchPath: "batch", defaultTrashLifetime: Rails.application.config.default_trash_lifetime, + blobSignatureTtl: Rails.application.config.blob_signature_ttl, + maxRequestSize: Rails.application.config.max_request_size, + dockerImageFormats: Rails.application.config.docker_image_formats, + crunchLogBytesPerEvent: Rails.application.config.crunch_log_bytes_per_event, + crunchLogSecondsBetweenEvents: Rails.application.config.crunch_log_seconds_between_events, + crunchLogThrottlePeriod: Rails.application.config.crunch_log_throttle_period, + crunchLogThrottleBytes: Rails.application.config.crunch_log_throttle_bytes, + crunchLogThrottleLines: Rails.application.config.crunch_log_throttle_lines, + crunchLimitLogBytesPerJob: Rails.application.config.crunch_limit_log_bytes_per_job, + crunchLogPartialLineThrottlePeriod: Rails.application.config.crunch_log_partial_line_throttle_period, + websocketUrl: Rails.application.config.websocket_address, parameters: { alt: { type: "string", @@ -72,12 +95,6 @@ class Arvados::V1::SchemaController < ApplicationController resources: {} } - if Rails.application.config.websocket_address - discovery[:websocketUrl] = Rails.application.config.websocket_address - elsif ENV['ARVADOS_WEBSOCKETS'] - discovery[:websocketUrl] = (root_url.sub /^http/, 'ws') + "websocket" - end - ActiveRecord::Base.descendants.reject(&:abstract_class?).each do |k| begin ctl_class = "Arvados::V1::#{k.to_s.pluralize}Controller".constantize @@ -176,14 +193,14 @@ class Arvados::V1::SchemaController < ApplicationController "https://api.curoverse.com/auth/arvados.readonly" ] }, - list: { - id: "arvados.#{k.to_s.underscore.pluralize}.list", + index: { + id: "arvados.#{k.to_s.underscore.pluralize}.index", path: k.to_s.underscore.pluralize, httpMethod: "GET", description: - %|List #{k.to_s.pluralize}. + %|Index #{k.to_s.pluralize}. - The list method returns a + The index method returns a resource list of matching #{k.to_s.pluralize}. For example: @@ -203,47 +220,6 @@ class Arvados::V1::SchemaController < ApplicationController } |, parameters: { - limit: { - type: "integer", - description: "Maximum number of #{k.to_s.underscore.pluralize} to return.", - default: "100", - format: "int32", - minimum: "0", - location: "query", - }, - offset: { - type: "integer", - description: "Number of #{k.to_s.underscore.pluralize} to skip before first returned record.", - default: "0", - format: "int32", - minimum: "0", - location: "query", - }, - filters: { - type: "array", - description: "Conditions for filtering #{k.to_s.underscore.pluralize}.", - location: "query" - }, - where: { - type: "object", - description: "Conditions for filtering #{k.to_s.underscore.pluralize}. (Deprecated. Use filters instead.)", - location: "query" - }, - order: { - type: "string", - description: "Order in which to return matching #{k.to_s.underscore.pluralize}.", - location: "query" - }, - select: { - type: "array", - description: "Select which fields to return", - location: "query" - }, - distinct: { - type: "boolean", - description: "Return each distinct object", - location: "query" - } }, response: { "$ref" => "#{k.to_s}List" @@ -367,28 +343,40 @@ class Arvados::V1::SchemaController < ApplicationController method = d_methods[action.to_sym] end if ctl_class.respond_to? "_#{action}_requires_parameters".to_sym - ctl_class.send("_#{action}_requires_parameters".to_sym).each do |k, v| + ctl_class.send("_#{action}_requires_parameters".to_sym).each do |l, v| if v.is_a? Hash - method[:parameters][k] = v + method[:parameters][l] = v else - method[:parameters][k] = {} + method[:parameters][l] = {} end - if !method[:parameters][k][:default].nil? + if !method[:parameters][l][:default].nil? # The JAVA SDK is sensitive to all values being strings - method[:parameters][k][:default] = method[:parameters][k][:default].to_s + method[:parameters][l][:default] = method[:parameters][l][:default].to_s end - method[:parameters][k][:type] ||= 'string' - method[:parameters][k][:description] ||= '' - method[:parameters][k][:location] = (route.segment_keys.include?(k) ? 'path' : 'query') - if method[:parameters][k][:required].nil? - method[:parameters][k][:required] = v != false + method[:parameters][l][:type] ||= 'string' + method[:parameters][l][:description] ||= '' + method[:parameters][l][:location] = (route.segment_keys.include?(l) ? 'path' : 'query') + if method[:parameters][l][:required].nil? + method[:parameters][l][:required] = v != false end end end d_methods[action.to_sym] = method + + if action == 'index' + list_method = method.dup + list_method[:id].sub!('index', 'list') + list_method[:description].sub!('Index', 'List') + list_method[:description].sub!('index', 'list') + d_methods[:list] = list_method + end end end end + Rails.configuration.disable_api_methods.each do |method| + ctrl, action = method.split('.', 2) + discovery[:resources][ctrl][:methods].delete(action.to_sym) + end discovery end send_json discovery