Return-Path: X-Original-To: apmail-deltacloud-commits-archive@www.apache.org Delivered-To: apmail-deltacloud-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 16144F65D for ; Wed, 27 Mar 2013 12:36:51 +0000 (UTC) Received: (qmail 27671 invoked by uid 500); 27 Mar 2013 12:36:50 -0000 Delivered-To: apmail-deltacloud-commits-archive@deltacloud.apache.org Received: (qmail 27598 invoked by uid 500); 27 Mar 2013 12:36:49 -0000 Mailing-List: contact commits-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list commits@deltacloud.apache.org Received: (qmail 27564 invoked by uid 99); 27 Mar 2013 12:36:48 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Mar 2013 12:36:48 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id EF5A2821CDE; Wed, 27 Mar 2013 12:36:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mfojtik@apache.org To: commits@deltacloud.apache.org Date: Wed, 27 Mar 2013 12:36:47 -0000 Message-Id: <3beb0c293bc84eeaadc42ba52ada02b8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: CIMI: Added 'generate_XXX_route' helpers for CIMI Updated Branches: refs/heads/master fd262d706 -> fcffad13e CIMI: Added 'generate_XXX_route' helpers for CIMI All CIMI entities share the same code in Rabbit operations. These helpers should merge them all to avoid code duplication. Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/f2df0087 Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/f2df0087 Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/f2df0087 Branch: refs/heads/master Commit: f2df00878be227479dbb3ba4c34062ce2d8bbaa1 Parents: fd262d7 Author: Michal Fojtik Authored: Wed Mar 27 08:56:11 2013 +0100 Committer: Michal fojtik Committed: Wed Mar 27 08:56:11 2013 +0100 ---------------------------------------------------------------------- server/lib/cimi/helpers/cimi_rabbit_helper.rb | 59 ++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltacloud/blob/f2df0087/server/lib/cimi/helpers/cimi_rabbit_helper.rb ---------------------------------------------------------------------- diff --git a/server/lib/cimi/helpers/cimi_rabbit_helper.rb b/server/lib/cimi/helpers/cimi_rabbit_helper.rb new file mode 100644 index 0000000..548262a --- /dev/null +++ b/server/lib/cimi/helpers/cimi_rabbit_helper.rb @@ -0,0 +1,59 @@ +module CIMI + module RabbitHelper + + def generate_delete_operation(opts={}) + collection_name = @collection_name.to_s.singularize.camelize + operation :destroy, :with_capability => opts[:with_capability] do + description "Delete specified Credential entity" + control do + CIMI::Service.const_get(collection_name).delete!(params[:id], self) + no_content_with_status(200) + end + end + end + + def generate_create_operation(opts={}) + collection_name = @collection_name.to_s.singularize.camelize + operation :create, :with_capability => opts[:with_capability] do + description "Create new #{collection_name} entity" + control do + ent = CIMI::Service.const_get("#{collection_name}Create").parse(self).create + headers_for_create ent + respond_to do |format| + format.json { ent.to_json } + format.xml { ent.to_xml } + end + end + end + end + + def generate_index_operation(opts={}) + collection_name = @collection_name.to_s.singularize.camelize + operation :index, :with_capability => opts[:with_capability] do + description "List all entities in #{collection_name} collection" + control do + ent = CIMI::Service.const_get(collection_name).list(self) + respond_to do |format| + format.xml { ent.to_xml } + format.json { ent.to_json } + end + end + end + end + + def generate_show_operation(opts={}) + collection_name = @collection_name.to_s.singularize.camelize + operation :show, :with_capability => opts[:with_capability] do + description "Show details about #{collection_name} entity" + control do + ent = CIMI::Service.const_get(collection_name).find(params[:id], self) + respond_to do |format| + format.xml { ent.to_xml } + format.json { ent.to_json } + end + end + end + end + + end +end