Class: OvirtSDK4::SshPublicKeyService

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

Instance Method Summary (collapse)

Instance Method Details

- (SshPublicKey) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
# File 'lib/ovirtsdk4/services.rb', line 17961

def get(opts = {})
  query = {}
  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 SshPublicKeyReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Object) remove(opts = {})

Deletes the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.



17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
# File 'lib/ovirtsdk4/services.rb', line 17985

def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = Request.new(:method => :DELETE, :path => @path, :query => query)
  response = @connection.send(request)
  unless response.code == 200
    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.

Raises:

  • (Error)


18036
18037
18038
18039
18040
18041
# File 'lib/ovirtsdk4/services.rb', line 18036

def service(path)
  if path.nil? || path == ''
    return self
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


18048
18049
18050
# File 'lib/ovirtsdk4/services.rb', line 18048

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

- (Object) update(key)

Updates the object managed by this service.



18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
# File 'lib/ovirtsdk4/services.rb', line 18002

def update(key)
  if key.is_a?(Hash)
    key = OvirtSDK4::SshPublicKey.new(key)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    SshPublicKeyWriter.write_one(key, writer, 'key')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return SshPublicKeyReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end