Class: WeBee::User
Instance Attribute Summary collapse
-
#enterprise_id ⇒ Object
Returns the value of attribute enterprise_id.
Class Method Summary collapse
- .all(enterprise = nil) ⇒ Object
-
.create(params) ⇒ Object
May raise exception if request is not successful.
- .find(user_id, enterprise) ⇒ Object
Instance Method Summary collapse
Methods included from SAXMachine
Instance Attribute Details
#enterprise_id ⇒ Object
Returns the value of attribute enterprise_id.
780 781 782 |
# File 'lib/webee.rb', line 780 def enterprise_id @enterprise_id end |
Class Method Details
.all(enterprise = nil) ⇒ Object
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
# File 'lib/webee.rb', line 823 def self.all(enterprise = nil) if enterprise.is_a? Enterprise enterprise_id = enterprise.resource_id else enterprise_id = enterprise end if enterprise.nil? enterprise_id = '_' end u = [] doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/enterprises/#{enterprise_id}/users")) doc.search('//user').each do |node| user = User.parse(node.to_s) u << user user.enterprise_id = enterprise_id end u end |
.create(params) ⇒ Object
May raise exception if request is not successful
795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
# File 'lib/webee.rb', line 795 def self.create(params) if params[:role] role = "<link rel='role' href='#{params[:role]}'/>" params.delete :role end eid = params[:enterprise].resource_id params.delete :enterprise xml = params.to_xml(:root => 'user') xml = xml.gsub('</user>', "#{role}</user>") res = RestClient.post(Api.url + "/admin/enterprises/#{eid}/users", xml, :content_type => :xml, :accept => :xml) user = User.parse(res) user.enterprise_id = eid user end |
.find(user_id, enterprise) ⇒ Object
814 815 816 817 818 819 820 821 |
# File 'lib/webee.rb', line 814 def self.find(user_id, enterprise) if enterprise.is_a? Enterprise enterprise_id = enterprise.resource_id else enterprise_id = enterprise end User.parse(RestClient.get(Api.url + "/admin/enterprises/#{enterprise_id}/users/#{user_id}")) end |
Instance Method Details
#delete ⇒ Object
810 811 812 |
# File 'lib/webee.rb', line 810 def delete RestClient.delete(Api.url + "/admin/enterprises/#{enterprise_id}/users/#{user_id}") end |
#enterprise ⇒ Object
851 852 853 854 |
# File 'lib/webee.rb', line 851 def enterprise doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/enterprises/#{enterprise_id}" , :accept => :xml)) Enterprise.parse doc.root.to_s end |
#virtual_machines ⇒ Object
842 843 844 845 846 847 848 849 |
# File 'lib/webee.rb', line 842 def virtual_machines items = [] doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/enterprises/#{enterprise_id}/users/#{user_id}/action/virtualmachines" , :accept => :xml)) doc.search('//virtualMachine').each do |node| items << VirtualMachine.parse(node.to_s) end items end |