Module: CIMI::RabbitHelper

Defined in:
lib/cimi/helpers/cimi_rabbit_helper.rb

Instance Method Summary collapse

Instance Method Details

#generate_add_to_system_operation(opts = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/cimi/helpers/cimi_rabbit_helper.rb', line 69

def generate_add_to_system_operation(opts={})
  collection_name = "System#{@collection_name.to_s.singularize.camelize}"
  operation :create, :with_capability => opts[:with_capability] do
    description "Add specified #{collection_name} entity to System"
    control do
      ent = CIMI::Service.const_get("#{collection_name}Create").parse(params[:id], self).create
      headers_for_create ent
      respond_to do |format|
        format.json { ent.to_json }
        format.xml { ent.to_xml }
      end
    end
  end
end

#generate_create_operation(opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cimi/helpers/cimi_rabbit_helper.rb', line 15

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

#generate_delete_operation(opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/cimi/helpers/cimi_rabbit_helper.rb', line 4

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

#generate_index_operation(opts = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cimi/helpers/cimi_rabbit_helper.rb', line 30

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

#generate_remove_from_system_operation(opts = {}) ⇒ Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/cimi/helpers/cimi_rabbit_helper.rb', line 58

def generate_remove_from_system_operation(opts={})
  collection_name = "System#{@collection_name.to_s.singularize.camelize}"
  operation :destroy, :with_capability => opts[:with_capability] do
    description "Remove specified #{collection_name} entity from System"
    control do
      CIMI::Service.const_get(collection_name).delete!(params[:id], self, params[:ent_id])
      no_content_with_status(200)
    end
  end
end

#generate_show_operation(opts = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cimi/helpers/cimi_rabbit_helper.rb', line 44

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

#generate_system_subcollection_index_operation(opts = {}) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/cimi/helpers/cimi_rabbit_helper.rb', line 84

def generate_system_subcollection_index_operation(opts={})
  collection_name = "System#{@collection_name.to_s.singularize.camelize}"
  operation :index, :with_capability => opts[:with_capability] do
    description "List all entities in System's #{collection_name} collection"
    control do
      ent = CIMI::Service.const_get(collection_name).collection_for_system(params[:id], self)
      respond_to do |format|
        format.xml { ent.to_xml }
        format.json { ent.to_json }
      end
    end
  end
end

#generate_system_subcollection_show_operation(opts = {}) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/cimi/helpers/cimi_rabbit_helper.rb', line 98

def generate_system_subcollection_show_operation(opts={})
  collection_name = "System#{@collection_name.to_s.singularize.camelize}"
  operation :show, :with_capability => opts[:with_capability] do
    description "Show details of System's #{collection_name} entity"
    control do
      ent = CIMI::Service.const_get(collection_name).find(params[:id], self, params[:ent_id])
      respond_to do |format|
        format.xml { ent.to_xml }
        format.json { ent.to_json }
      end
    end
  end
end