Class: OvirtSDK4::QuotaService

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

Instance Method Summary (collapse)

Instance Method Details

- (Quota) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
# File 'lib/ovirtsdk4/services.rb', line 15815

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

- (AssignedPermissionsService) permissions_service

Locates the permissions service.

Returns:



15887
15888
15889
# File 'lib/ovirtsdk4/services.rb', line 15887

def permissions_service
  return AssignedPermissionsService.new(@connection, "#{@path}/permissions")
end

- (QuotaClusterLimitsService) quota_cluster_limits_service

Locates the quota_cluster_limits service.

Returns:



15895
15896
15897
# File 'lib/ovirtsdk4/services.rb', line 15895

def quota_cluster_limits_service
  return QuotaClusterLimitsService.new(@connection, "#{@path}/quotaclusterlimits")
end

- (QuotaStorageLimitsService) quota_storage_limits_service

Locates the quota_storage_limits service.

Returns:



15903
15904
15905
# File 'lib/ovirtsdk4/services.rb', line 15903

def quota_storage_limits_service
  return QuotaStorageLimitsService.new(@connection, "#{@path}/quotastoragelimits")
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.



15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
# File 'lib/ovirtsdk4/services.rb', line 15839

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)


15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
# File 'lib/ovirtsdk4/services.rb', line 15914

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-1])
  end
  if path == 'quotaclusterlimits'
    return quota_cluster_limits_service
  end
  if path.start_with?('quotaclusterlimits/')
    return quota_cluster_limits_service.service(path[19..-1])
  end
  if path == 'quotastoragelimits'
    return quota_storage_limits_service
  end
  if path.start_with?('quotastoragelimits/')
    return quota_storage_limits_service.service(path[19..-1])
  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)


15944
15945
15946
# File 'lib/ovirtsdk4/services.rb', line 15944

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

- (Object) update(quota)

Updates the object managed by this service.



15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
# File 'lib/ovirtsdk4/services.rb', line 15856

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