Class: OvirtSDK4::AssignedDiskProfilesService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::AssignedDiskProfilesService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (DiskProfile) add(profile, opts = {})
Adds a new
profile
. -
- (Array<DiskProfile>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (AssignedDiskProfileService) 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
- (DiskProfile) add(profile, opts = {})
Adds a new profile
.
2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 |
# File 'lib/ovirtsdk4/services.rb', line 2317 def add(profile, opts = {}) if profile.is_a?(Hash) profile = OvirtSDK4::DiskProfile.new(profile) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) DiskProfileWriter.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 DiskProfileReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Array<DiskProfile>) list(opts = {})
Returns the representation of the object managed by this service.
2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 |
# File 'lib/ovirtsdk4/services.rb', line 2352 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 DiskProfileReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (AssignedDiskProfileService) profile_service(id)
Locates the profile
service.
2381 2382 2383 |
# File 'lib/ovirtsdk4/services.rb', line 2381 def profile_service(id) return AssignedDiskProfileService.new(@connection, "#{@path}/#{id}") end |
- (Service) service(path)
Locates the service corresponding to the given path.
2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 |
# File 'lib/ovirtsdk4/services.rb', line 2392 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.
2408 2409 2410 |
# File 'lib/ovirtsdk4/services.rb', line 2408 def to_s return "#<#{AssignedDiskProfilesService}:#{@path}>" end |