Class: OvirtSDK4::ClustersService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::ClustersService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Cluster) add(cluster, opts = {})
Adds a new
cluster
. -
- (ClusterService) cluster_service(id)
Locates the
cluster
service. -
- (Array<Cluster>) 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
- (Cluster) add(cluster, opts = {})
Adds a new cluster
.
4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 |
# File 'lib/ovirtsdk4/services.rb', line 4411 def add(cluster, opts = {}) if cluster.is_a?(Hash) cluster = OvirtSDK4::Cluster.new(cluster) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) ClusterWriter.write_one(cluster, writer, 'cluster') 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 ClusterReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (ClusterService) cluster_service(id)
Locates the cluster
service.
4497 4498 4499 |
# File 'lib/ovirtsdk4/services.rb', line 4497 def cluster_service(id) return ClusterService.new(@connection, "#{@path}/#{id}") end |
- (Array<Cluster>) list(opts = {})
Returns the representation of the object managed by this service.
4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 |
# File 'lib/ovirtsdk4/services.rb', line 4454 def list(opts = {}) query = {} value = opts[:case_sensitive] unless value.nil? value = Writer.render_boolean(value) query['case_sensitive'] = value end 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 value = opts[:search] unless value.nil? query['search'] = 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 ClusterReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 |
# File 'lib/ovirtsdk4/services.rb', line 4508 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return cluster_service(path) end return cluster_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
4524 4525 4526 |
# File 'lib/ovirtsdk4/services.rb', line 4524 def to_s return "#<#{ClustersService}:#{@path}>" end |