X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4696633ae5e955c267d50a14e790c93d833f41b0..7caabd9c19c46ebc218d10b2c048e36d6e8cb2a4:/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 e2537a578a..aee5d1f951 100644 --- a/services/api/app/controllers/arvados/v1/schema_controller.rb +++ b/services/api/app/controllers/arvados/v1/schema_controller.rb @@ -1,42 +1,78 @@ +# 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 + skip_before_action :catch_redirect_hint + skip_before_action :find_objects_for_index + skip_before_action :find_object_by_uuid + skip_before_action :load_filters_param + skip_before_action :load_limit_offset_order_params + skip_before_action :load_read_auths + skip_before_action :load_where_param + skip_before_action :render_404_if_no_object + skip_before_action :require_auth_scope include DbCurrentTime def index expires_in 24.hours, public: true - discovery = Rails.cache.fetch 'arvados_v1_rest_discovery' do + send_json discovery_doc + end + + protected + + def discovery_doc + Rails.cache.fetch 'arvados_v1_rest_discovery' do Rails.application.eager_load! + remoteHosts = {} + Rails.configuration.RemoteClusters.each {|k,v| if k != :"*" then remoteHosts[k] = v["Host"] end } discovery = { kind: "discovery#restDescription", discoveryVersion: "v1", id: "arvados:v1", name: "arvados", version: "v1", - revision: "20131114", + # format is YYYYMMDD, must be fixed with (needs to be linearly + # sortable), updated manually, may be used by clients to + # determine availability of API server features. + revision: "20190926", source_version: AppVersion.hash, + sourceVersion: AppVersion.hash, # source_version should be deprecated in the future + packageVersion: AppVersion.package_version, 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, + defaultCollectionReplication: Rails.configuration.Collections.DefaultReplication, protocol: "rest", baseUrl: root_url + "arvados/v1/", basePath: "/arvados/v1/", rootUrl: root_url, 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, + uuidPrefix: Rails.configuration.ClusterID, + defaultTrashLifetime: Rails.configuration.Collections.DefaultTrashLifetime, + blobSignatureTtl: Rails.configuration.Collections.BlobSigningTTL, + maxRequestSize: Rails.configuration.API.MaxRequestSize, + maxItemsPerResponse: Rails.configuration.API.MaxItemsPerResponse, + dockerImageFormats: Rails.configuration.Containers.SupportedDockerImageFormats.keys, + crunchLogBytesPerEvent: Rails.configuration.Containers.Logging.LogBytesPerEvent, + crunchLogSecondsBetweenEvents: Rails.configuration.Containers.Logging.LogSecondsBetweenEvents, + crunchLogThrottlePeriod: Rails.configuration.Containers.Logging.LogThrottlePeriod, + crunchLogThrottleBytes: Rails.configuration.Containers.Logging.LogThrottleBytes, + crunchLogThrottleLines: Rails.configuration.Containers.Logging.LogThrottleLines, + crunchLimitLogBytesPerJob: Rails.configuration.Containers.Logging.LimitLogBytesPerJob, + crunchLogPartialLineThrottlePeriod: Rails.configuration.Containers.Logging.LogPartialLineThrottlePeriod, + crunchLogUpdatePeriod: Rails.configuration.Containers.Logging.LogUpdatePeriod, + crunchLogUpdateSize: Rails.configuration.Containers.Logging.LogUpdateSize, + remoteHosts: remoteHosts, + remoteHostsViaDNS: Rails.configuration.RemoteClusters["*"].Proxy, + websocketUrl: Rails.configuration.Services.Websocket.ExternalURL.to_s, + workbenchUrl: Rails.configuration.Services.Workbench1.ExternalURL.to_s, + workbench2Url: Rails.configuration.Services.Workbench2.ExternalURL.to_s, + keepWebServiceUrl: Rails.configuration.Services.WebDAV.ExternalURL.to_s, + gitUrl: Rails.configuration.Services.GitHTTP.ExternalURL.to_s, parameters: { alt: { type: "string", @@ -82,12 +118,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 @@ -97,12 +127,20 @@ class Arvados::V1::SchemaController < ApplicationController end object_properties = {} k.columns. - select { |col| col.name != 'id' }. + select { |col| col.name != 'id' && !col.name.start_with?('secret_') }. collect do |col| if k.serialized_attributes.has_key? col.name object_properties[col.name] = { type: k.serialized_attributes[col.name].object_class.to_s } + elsif k.attribute_types[col.name].is_a? JsonbType::Hash + object_properties[col.name] = { + type: Hash.to_s + } + elsif k.attribute_types[col.name].is_a? JsonbType::Array + object_properties[col.name] = { + type: Array.to_s + } else object_properties[col.name] = { type: col.type @@ -186,14 +224,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: @@ -213,53 +251,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" - }, - count: { - type: "string", - description: "Type of count to return in items_available ('none' or 'exact').", - default: "exact", - location: "query" - } }, response: { "$ref" => "#{k.to_s}List" @@ -402,15 +393,44 @@ class Arvados::V1::SchemaController < ApplicationController 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]['configs'] = { + methods: { + get: { + id: "arvados.configs.get", + path: "config", + httpMethod: "GET", + description: "Get public config", + parameters: { + }, + parameterOrder: [ + ], + response: { + }, + scopes: [ + "https://api.curoverse.com/auth/arvados", + "https://api.curoverse.com/auth/arvados.readonly" + ] + }, + } + } + + Rails.configuration.API.DisabledAPIs.each do |method, _| + ctrl, action = method.to_s.split('.', 2) discovery[:resources][ctrl][:methods].delete(action.to_sym) end discovery end - send_json discovery end end