Class: OvirtSDK4::RoleService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::RoleService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Role) get(opts = {})
Returns the representation of the object managed by this service.
-
- (PermitsService) permits_service
Locates the
permits
service. -
- (Object) remove(opts = {})
Deletes the object managed by this service.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
-
- (Object) update(role)
Updates the object managed by this service.
Instance Method Details
- (Role) get(opts = {})
Returns the representation of the object managed by this service.
16505 16506 16507 16508 16509 16510 16511 16512 16513 16514 16515 16516 16517 16518 16519 16520 |
# File 'lib/ovirtsdk4/services.rb', line 16505 def get(opts = {}) query = {} request = Request.new(:method => :GET, :path => @path, :query => query) response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return RoleReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (PermitsService) permits_service
Locates the permits
service.
16577 16578 16579 |
# File 'lib/ovirtsdk4/services.rb', line 16577 def permits_service return PermitsService.new(@connection, "#{@path}/permits") end |
- (Object) remove(opts = {})
Deletes the object managed by this service.
16529 16530 16531 16532 16533 16534 16535 16536 16537 16538 16539 16540 16541 |
# File 'lib/ovirtsdk4/services.rb', line 16529 def remove(opts = {}) query = {} value = opts[:async] unless value.nil? value = Writer.render_boolean(value) query['async'] = value end request = Request.new(:method => :DELETE, :path => @path, :query => query) response = @connection.send(request) unless response.code == 200 check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 |
# File 'lib/ovirtsdk4/services.rb', line 16588 def service(path) if path.nil? || path == '' return self end if path == 'permits' return permits_service end if path.start_with?('permits/') return permits_service.service(path[8..-1]) end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end |
- (String) to_s
Returns an string representation of this service.
16606 16607 16608 |
# File 'lib/ovirtsdk4/services.rb', line 16606 def to_s return "#<#{RoleService}:#{@path}>" end |
- (Object) update(role)
Updates the object managed by this service.
16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 |
# File 'lib/ovirtsdk4/services.rb', line 16546 def update(role) if role.is_a?(Hash) role = OvirtSDK4::Role.new(role) end request = Request.new(:method => :PUT, :path => @path) begin writer = XmlWriter.new(nil, true) RoleWriter.write_one(role, writer, 'role') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return RoleReader.read_one(reader) ensure reader.close end return result else check_fault(response) end end |