Class: Vcloud::Core::QueryRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/core/query_runner.rb

Instance Method Summary collapse

Constructor Details

#initializeQueryRunner

Create a new instance of the ServiceInterface as the @fsi global



6
7
8
# File 'lib/vcloud/core/query_runner.rb', line 6

def initialize
  @fsi = Vcloud::Core::Fog::ServiceInterface.new
end

Instance Method Details

#available_query_typesArray

List the available entity types which can be queried

See integration test of this module for examples

Returns:

  • (Array)

    list of valid types



37
38
39
40
# File 'lib/vcloud/core/query_runner.rb', line 37

def available_query_types
  query_body = @fsi.get_execute_query()
  get_entity_types_in_record_format(query_body)
end

#run(type = nil, options = {}) ⇒ Array

Run a query (optionally for a particular entity type)

Parameters:

  • type (String) (defaults to: nil)

    Name of type to query for - default: nil See integration test of this module for examples

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

    options for the query API see Fog::Compute::VcloudDirector::Real for more documentation of valid options. Default: {}

Options Hash (options):

  • :filter (String)

    Filter the query e.g. “name==foo”

  • :format (String)

    Unsupported - do not use

  • :page (String)

    Override automatic pagination

  • :pageSize (String)

    Override automatic pagination

Returns:

  • (Array)

    List of results

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
31
# File 'lib/vcloud/core/query_runner.rb', line 23

def run(type=nil, options={})
  raise ArgumentError, "Query API :format option is not supported" if options[:format]

  if options.has_key?(:page) || options.has_key?(:pageSize)
    get_results_page(options.fetch(:page, 1), type, options) || []
  else
    get_all_results(type, options)
  end
end