add delete method. refs #1406
[arvados.git] / app / controllers / orvos / v1 / schema_controller.rb
index 060665e090a5ffdd71290f4d3efeaecebd973bee..11465a74675e684af72a9af426a121ab7039864e 100644 (file)
@@ -3,7 +3,7 @@ class Orvos::V1::SchemaController < ApplicationController
   skip_before_filter :login_required
 
   def show
-    classes = Rails.cache.fetch 'discovery_rest_description' do
+    classes = Rails.cache.fetch 'orvos_v1_schema' do
       Rails.application.eager_load!
       classes = {}
       ActiveRecord::Base.descendants.reject(&:abstract_class?).each do |k|
@@ -23,7 +23,7 @@ class Orvos::V1::SchemaController < ApplicationController
   end
 
   def discovery_rest_description
-    discovery = Rails.cache.fetch 'discovery_rest_description' do
+    discovery = Rails.cache.fetch 'orvos_v1_rest_discovery' do
       Rails.application.eager_load!
       discovery = {
         kind: "discovery#restDescription",
@@ -154,11 +154,11 @@ class Orvos::V1::SchemaController < ApplicationController
               id: "orvos.#{k.to_s.underscore.pluralize}.get",
               path: "#{k.to_s.underscore.pluralize}/{uuid}",
               httpMethod: "GET",
-              description: "Gets a #{k.to_s}'s metadata by ID.",
+              description: "Gets a #{k.to_s}'s metadata by UUID.",
               parameters: {
                 uuid: {
                   type: "string",
-                  description: "The ID for the #{k.to_s} in question.",
+                  description: "The UUID of the #{k.to_s} in question.",
                   required: true,
                   location: "path"
                 }
@@ -206,6 +206,78 @@ class Orvos::V1::SchemaController < ApplicationController
                        "https://api.clinicalfuture.com/auth/orvos",
                        "https://api.clinicalfuture.com/auth/orvos.readonly"
                       ]
+            },
+            create: {
+              id: "orvos.#{k.to_s.underscore.pluralize}.create",
+              path: "#{k.to_s.underscore.pluralize}",
+              httpMethod: "POST",
+              description: "Create a new #{k.to_s}.",
+              parameters: {
+                k.to_s.underscore => {
+                  type: "object",
+                  required: true,
+                  location: "query",
+                  properties: object_properties
+                }
+              },
+              request: {
+                "$ref" => k.to_s
+              },
+              response: {
+                "$ref" => k.to_s
+              },
+              scopes: [
+                       "https://api.clinicalfuture.com/auth/orvos"
+                      ]
+            },
+            update: {
+              id: "orvos.#{k.to_s.underscore.pluralize}.update",
+              path: "#{k.to_s.underscore.pluralize}/{uuid}",
+              httpMethod: "PUT",
+              description: "Update attributes of an existing #{k.to_s}.",
+              parameters: {
+                uuid: {
+                  type: "string",
+                  description: "The UUID of the #{k.to_s} in question.",
+                  required: true,
+                  location: "path"
+                },
+                k.to_s.underscore => {
+                  type: "object",
+                  required: true,
+                  location: "query",
+                  properties: object_properties
+                }
+              },
+              request: {
+                "$ref" => k.to_s
+              },
+              response: {
+                "$ref" => k.to_s
+              },
+              scopes: [
+                       "https://api.clinicalfuture.com/auth/orvos"
+                      ]
+            },
+            delete: {
+              id: "orvos.#{k.to_s.underscore.pluralize}.delete",
+              path: "#{k.to_s.underscore.pluralize}/{uuid}",
+              httpMethod: "DELETE",
+              description: "Delete an existing #{k.to_s}.",
+              parameters: {
+                uuid: {
+                  type: "string",
+                  description: "The UUID of the #{k.to_s} in question.",
+                  required: true,
+                  location: "path"
+                }
+              },
+              response: {
+                "$ref" => k.to_s
+              },
+              scopes: [
+                       "https://api.clinicalfuture.com/auth/orvos"
+                      ]
             }
           }
         }