Class: NexposeSCCM::DataSource::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose_sccm/data_source.rb

Overview

Connection object to interact with SCCM and SCCM utilities

  • Args :

    • data_source - A String identifying ‘nsc’ or ‘dwh’ for the source of Nexpose data

    • pg - A Hash identifying the Postgres connection settings

    • nx - A Hash identifying the Nexpose connection settings

Instance Method Summary collapse

Constructor Details

#initialize(data_source = 'nsc', pg = nil, nx = nil) ⇒ Connection

Returns a new instance of Connection.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nexpose_sccm/data_source.rb', line 11

def initialize(data_source='nsc', pg=nil, nx=nil)
  connection_type = data_source

  if connection_type.casecmp('dwh') == 0
    @connection_type = :dwh
    unless pg.nil?
      require_relative 'helpers/pg_helper'
      @conn = Helpers::PGHelper::Connection.new(pg)
    end
  else
    @connection_type = :nsc
    unless nx.nil?
      require_relative 'helpers/nexpose_helper'
      @conn = Helpers::NexposeHelper::Connection.new(nx)
    end
  end
end

Instance Method Details

#fetch_data(query) ⇒ Object



29
30
31
32
# File 'lib/nexpose_sccm/data_source.rb', line 29

def fetch_data(query)
  res = @conn.get_data(query)
  Data.new(res, @connection_type)
end