Class: GProv::Provision::User
- Defined in:
- lib/gprov/provision/user.rb
Instance Attribute Summary collapse
-
#hash_function_name ⇒ Object
These attributes appear to never be sent from google but can be posted back.
-
#password ⇒ Object
These attributes appear to never be sent from google but can be posted back.
Attributes inherited from EntryBase
Class Method Summary collapse
-
.all(connection) ⇒ Object
Retrieves all users within a domain.
-
.attribute_names ⇒ Object
Adds explicit ordering to attributes for cleaner output.
- .get(connection, title, options = {}) ⇒ Object
Instance Method Summary collapse
- #create! ⇒ Object
- #delete! ⇒ Object
-
#to_nokogiri ⇒ Object
Generate a nokogiri representation of this user.
- #update! ⇒ Object
Methods inherited from EntryBase
#attributes_from_hash, #initialize, #xml_to_hash
Methods included from EntryBase::ClassMethods
#attribute_names, #attribute_titles, #attributes, #xmlattr
Constructor Details
This class inherits a constructor from GProv::Provision::EntryBase
Instance Attribute Details
#hash_function_name ⇒ Object
These attributes appear to never be sent from google but can be posted back
53 54 55 |
# File 'lib/gprov/provision/user.rb', line 53 def hash_function_name @hash_function_name end |
#password ⇒ Object
These attributes appear to never be sent from google but can be posted back
53 54 55 |
# File 'lib/gprov/provision/user.rb', line 53 def password @password end |
Class Method Details
.all(connection) ⇒ Object
Retrieves all users within a domain
56 57 58 59 60 |
# File 'lib/gprov/provision/user.rb', line 56 def self.all(connection) feed = GProv::Provision::Feed.new(connection, "/:domain/user/2.0", "/xmlns:feed/xmlns:entry") entries = feed.fetch entries.map { |xml| new(:status => :clean, :connection => connection, :source => xml) } end |
.attribute_names ⇒ Object
Adds explicit ordering to attributes for cleaner output
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/gprov/provision/user.rb', line 37 def self.attribute_names [ :user_name, :given_name, :family_name, :admin, :agreed_to_terms, :change_password_at_next_login, :suspended, :ip_whitelisted, :limit ] end |
.get(connection, title, options = {}) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/gprov/provision/user.rb', line 62 def self.get(connection, title, ={}) response = connection.get("/:domain/user/2.0/#{title}") document = Nokogiri::XML(response.body) xml = document.root new(:status => :clean, :connection => connection, :source => xml) end |
Instance Method Details
#create! ⇒ Object
91 92 93 94 |
# File 'lib/gprov/provision/user.rb', line 91 def create! response = connection.post("/:domain/user/2.0", {:body => to_nokogiri.to_xml}) status = :clean end |
#delete! ⇒ Object
101 102 103 104 |
# File 'lib/gprov/provision/user.rb', line 101 def delete! response = connection.delete("/:domain/user/2.0/#{title}") status = :deleted end |
#to_nokogiri ⇒ Object
Generate a nokogiri representation of this user
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/gprov/provision/user.rb', line 72 def to_nokogiri base_document = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml| xml.entry('xmlns:atom' => 'http://www.w3.org/2005/Atom', 'xmlns:apps' => 'http://schemas.google.com/apps/2006' ) { # Namespaces cannot be used until they are declared, so we need to # retroactively declare the namespace of the parent xml.parent.namespace = xml.parent.namespace_definitions.select {|ns| ns.prefix == "atom"}.first xml.category("scheme" => "http://schemas.google.com/g/2005#kind", "term" =>"http://schemas.google.com/apps/2006#user") xml['apps'].login(login_attributes) xml['apps'].quota("limit" => @limit) if @limit xml['apps'].name("familyName" => @family_name, "givenName" => @given_name) } end base_document end |
#update! ⇒ Object
96 97 98 99 |
# File 'lib/gprov/provision/user.rb', line 96 def update! response = connection.put("/:domain/user/2.0/#{title}", {:body => to_nokogiri.to_xml}) status = :clean end |