Class: OvirtSDK4::BalancesService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::BalancesService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Balance) add(balance, opts = {})
Adds a new
balance
. -
- (BalanceService) balance_service(id)
Locates the
balance
service. -
- (Array<Balance>) list(opts = {})
Returns the representation of 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.
Instance Method Details
- (Balance) add(balance, opts = {})
Adds a new balance
.
3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 |
# File 'lib/ovirtsdk4/services.rb', line 3659 def add(balance, opts = {}) if balance.is_a?(Hash) balance = OvirtSDK4::Balance.new(balance) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) BalanceWriter.write_one(balance, writer, 'balance') 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 BalanceReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (BalanceService) balance_service(id)
Locates the balance
service.
3730 3731 3732 |
# File 'lib/ovirtsdk4/services.rb', line 3730 def balance_service(id) return BalanceService.new(@connection, "#{@path}/#{id}") end |
- (Array<Balance>) list(opts = {})
Returns the representation of the object managed by this service.
3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 |
# File 'lib/ovirtsdk4/services.rb', line 3696 def list(opts = {}) query = {} value = opts[:filter] unless value.nil? value = Writer.render_boolean(value) query['filter'] = value end 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 BalanceReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 |
# File 'lib/ovirtsdk4/services.rb', line 3741 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return balance_service(path) end return balance_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
3757 3758 3759 |
# File 'lib/ovirtsdk4/services.rb', line 3757 def to_s return "#<#{BalancesService}:#{@path}>" end |