Class: OvirtSDK4::SchedulingPoliciesService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::SchedulingPoliciesService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (SchedulingPolicy) add(policy, opts = {})
Adds a new
policy
. -
- (Array<SchedulingPolicy>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (SchedulingPolicyService) policy_service(id)
Locates the
policy
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
- (SchedulingPolicy) add(policy, opts = {})
Adds a new policy
.
16755 16756 16757 16758 16759 16760 16761 16762 16763 16764 16765 16766 16767 16768 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 |
# File 'lib/ovirtsdk4/services.rb', line 16755 def add(policy, opts = {}) if policy.is_a?(Hash) policy = OvirtSDK4::SchedulingPolicy.new(policy) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) SchedulingPolicyWriter.write_one(policy, writer, 'policy') 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 SchedulingPolicyReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Array<SchedulingPolicy>) list(opts = {})
Returns the representation of the object managed by this service.
16792 16793 16794 16795 16796 16797 16798 16799 16800 16801 16802 16803 16804 16805 16806 16807 16808 16809 16810 16811 16812 16813 16814 16815 16816 16817 |
# File 'lib/ovirtsdk4/services.rb', line 16792 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 SchedulingPolicyReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (SchedulingPolicyService) policy_service(id)
Locates the policy
service.
16826 16827 16828 |
# File 'lib/ovirtsdk4/services.rb', line 16826 def policy_service(id) return SchedulingPolicyService.new(@connection, "#{@path}/#{id}") end |
- (Service) service(path)
Locates the service corresponding to the given path.
16837 16838 16839 16840 16841 16842 16843 16844 16845 16846 |
# File 'lib/ovirtsdk4/services.rb', line 16837 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return policy_service(path) end return policy_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
16853 16854 16855 |
# File 'lib/ovirtsdk4/services.rb', line 16853 def to_s return "#<#{SchedulingPoliciesService}:#{@path}>" end |