Class: GProv::Provision::OrgUnit
Instance Attribute Summary
Attributes inherited from EntryBase
#connection, #status
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from EntryBase
#attributes_from_hash, #initialize, #xml_to_hash
#attribute_names, #attribute_titles, #attributes, #xmlattr
Class Method Details
.all(connection) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/gprov/provision/orgunit.rb', line 30
def self.all(connection)
id = GProv::Provision::CustomerID.get(connection)
feed = GProv::Provision::Feed.new(connection, "/orgunit/2.0/#{id.customer_id}?get=all", "/xmlns:feed/xmlns:entry")
entries = feed.fetch
entries.map { |xml| new(:status => :clean, :connection => connection, :source => xml) }
end
|
.get(connection, org_path) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/gprov/provision/orgunit.rb', line 37
def self.get(connection, org_path)
id = GProv::Provision::CustomerID.get(connection)
response = connection.get("/orgunit/2.0/#{id.customer_id}/#{org_path}")
document = Nokogiri::XML(response.body)
xml = document.root
new(:status => :clean, :connection => connection, :source => xml)
end
|
Instance Method Details
#create! ⇒ Object
64
65
66
67
68
69
|
# File 'lib/gprov/provision/orgunit.rb', line 64
def create!
id = GProv::Provision::CustomerID.get(connection)
response = connection.post("/orgunit/2.0/#{id.customer_id}")
status = :clean
end
|
#delete! ⇒ Object
78
79
80
81
82
|
# File 'lib/gprov/provision/orgunit.rb', line 78
def delete!
id = GProv::Provision::Customerid.get(connection)
response = connection.delete("/orgunit/2.0/#{id.customer_id}/#{@org_unit_path}")
status = :deleted
end
|
#list_members ⇒ Object
84
85
86
|
# File 'lib/gprov/provision/orgunit.rb', line 84
def list_members
GProv::Provision::OrgMember.all(connection, :target => :orgunit, :orgunit => @org_unit_path)
end
|
#to_nokogiri ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/gprov/provision/orgunit.rb', line 46
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',
'xmlns:gd' => "http://schemas.google.com/g/2005" ) {
xml.parent.namespace = xml.parent.namespace_definitions.select {|ns| ns.prefix == "atom"}.first
xml['apps'].property("name" => "name", "value" => @name)
xml['apps'].property("name" => "description", "value" => @description)
xml['apps'].property("name" => "parentOrgUnitPath", "value" => @parent_org_unit_path)
xml['apps'].property("name" => "blockInheritance", "value" => @block_inheritance)
}
end
end
|
#update! ⇒ Object
71
72
73
74
75
76
|
# File 'lib/gprov/provision/orgunit.rb', line 71
def update!
id = GProv::Provision::Customerid.get(connection)
response = connection.put("/orgunit/2.0/#{id.customer_id}/#{@org_unit_path}")
status = :clean
end
|