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.
859 860 861 |
# File 'lib/webee.rb', line 859 def enterprise_id @enterprise_id end |
Class Method Details
.all(enterprise = nil) ⇒ Object
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
# File 'lib/webee.rb', line 902 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", :accept => :xml)) 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
874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
# File 'lib/webee.rb', line 874 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
893 894 895 896 897 898 899 900 |
# File 'lib/webee.rb', line 893 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}", :accept => :xml)) end |
Instance Method Details
#delete ⇒ Object
889 890 891 |
# File 'lib/webee.rb', line 889 def delete RestClient.delete(Api.url + "/admin/enterprises/#{enterprise_id}/users/#{user_id}") end |
#enterprise ⇒ Object
930 931 932 933 |
# File 'lib/webee.rb', line 930 def enterprise doc = Nokogiri.parse(RestClient.get(Api.build_url(enterprise_url) , :accept => :xml)) Enterprise.parse doc.root.to_s end |
#virtual_machines ⇒ Object
921 922 923 924 925 926 927 928 |
# File 'lib/webee.rb', line 921 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 |