Class: OvirtSDK4::StepsService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

- (Step) add(step, opts = {})

Adds a new step.

Parameters:

Returns:



18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
# File 'lib/ovirtsdk4/services.rb', line 18457

def add(step, opts = {})
  if step.is_a?(Hash)
    step = OvirtSDK4::Step.new(step)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    StepWriter.write_one(step, writer, 'step')
    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 StepReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Array<Step>) list(opts = {})

Returns the representation of the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :max (Integer)

    Sets the maximum number of steps to return. If not specified all the steps are returned.

Returns:



18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
# File 'lib/ovirtsdk4/services.rb', line 18492

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 StepReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Service) service(path)

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
# File 'lib/ovirtsdk4/services.rb', line 18532

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return step_service(path)
  end
  return step_service(path[0..(index - 1)]).service(path[(index +1)..-1])
end

- (StepService) step_service(id)

Locates the step service.

Parameters:

  • id (String)

    The identifier of the step.

Returns:



18521
18522
18523
# File 'lib/ovirtsdk4/services.rb', line 18521

def step_service(id)
  return StepService.new(@connection, "#{@path}/#{id}")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


18548
18549
18550
# File 'lib/ovirtsdk4/services.rb', line 18548

def to_s
  return "#<#{StepsService}:#{@path}>"
end