Class: OvirtSDK4::RolesService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::RolesService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Role) add(role, opts = {})
Adds a new
role
. -
- (Array<Role>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (RoleService) role_service(id)
Sub-resource locator method, returns individual role resource on which the remainder of the URI is dispatched.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
Instance Method Details
- (Role) add(role, opts = {})
Adds a new role
.
16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 |
# File 'lib/ovirtsdk4/services.rb', line 16635 def add(role, opts = {}) if role.is_a?(Hash) role = OvirtSDK4::Role.new(role) end request = Request.new(:method => :POST, :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 201, 202 begin reader = XmlReader.new(response.body) return RoleReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Array<Role>) list(opts = {})
Returns the representation of the object managed by this service.
16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 16683 16684 16685 16686 16687 16688 16689 16690 |
# File 'lib/ovirtsdk4/services.rb', line 16670 def list(opts = {}) query = {} value = opts[:max] unless value.nil? value = Writer.render_integer(value) query['max'] = value end 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_many(reader) ensure reader.close end else check_fault(response) end end |
- (RoleService) role_service(id)
Sub-resource locator method, returns individual role resource on which the remainder of the URI is dispatched.
16699 16700 16701 |
# File 'lib/ovirtsdk4/services.rb', line 16699 def role_service(id) return RoleService.new(@connection, "#{@path}/#{id}") end |
- (Service) service(path)
Locates the service corresponding to the given path.
16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 |
# File 'lib/ovirtsdk4/services.rb', line 16710 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return role_service(path) end return role_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
16726 16727 16728 |
# File 'lib/ovirtsdk4/services.rb', line 16726 def to_s return "#<#{RolesService}:#{@path}>" end |