Class: OvirtSDK4::CpuProfilesService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::CpuProfilesService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (CpuProfile) add(profile, opts = {})
Adds a new
profile
. -
- (Array<CpuProfile>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (CpuProfileService) profile_service(id)
Locates the
profile
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
- (CpuProfile) add(profile, opts = {})
Adds a new profile
.
4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 |
# File 'lib/ovirtsdk4/services.rb', line 4747 def add(profile, opts = {}) if profile.is_a?(Hash) profile = OvirtSDK4::CpuProfile.new(profile) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) CpuProfileWriter.write_one(profile, writer, 'profile') 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 CpuProfileReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Array<CpuProfile>) list(opts = {})
Returns the representation of the object managed by this service.
4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 |
# File 'lib/ovirtsdk4/services.rb', line 4782 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 CpuProfileReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (CpuProfileService) profile_service(id)
Locates the profile
service.
4811 4812 4813 |
# File 'lib/ovirtsdk4/services.rb', line 4811 def profile_service(id) return CpuProfileService.new(@connection, "#{@path}/#{id}") end |
- (Service) service(path)
Locates the service corresponding to the given path.
4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 |
# File 'lib/ovirtsdk4/services.rb', line 4822 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return profile_service(path) end return profile_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
4838 4839 4840 |
# File 'lib/ovirtsdk4/services.rb', line 4838 def to_s return "#<#{CpuProfilesService}:#{@path}>" end |