Class: Jbcm::Client

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

Defined Under Namespace

Classes: Job

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
# File 'lib/jbcm.rb', line 10

def initialize(opts = {})
  @user_name = opts[:user_name]
  @api_token = opts[:api_token]
  @api_token = opts[:password] if opts[:password]
  @scheme = opts[:scheme] || 'https'
  @hostname = opts[:hostname]
  @port = opts[:port] || '443'
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



8
9
10
# File 'lib/jbcm.rb', line 8

def api_token
  @api_token
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



8
9
10
# File 'lib/jbcm.rb', line 8

def hostname
  @hostname
end

#passwordObject (readonly)

Returns the value of attribute password.



8
9
10
# File 'lib/jbcm.rb', line 8

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



8
9
10
# File 'lib/jbcm.rb', line 8

def port
  @port
end

#schemeObject (readonly)

Returns the value of attribute scheme.



8
9
10
# File 'lib/jbcm.rb', line 8

def scheme
  @scheme
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



8
9
10
# File 'lib/jbcm.rb', line 8

def user_name
  @user_name
end

Instance Method Details

#connObject



19
20
21
22
23
24
# File 'lib/jbcm.rb', line 19

def conn
  conn ||= Faraday::Connection.new(url: "#{scheme}://#{user_name}:#{api_token}@#{hostname}:#{port}") do |builder|
    builder.use Faraday::Request::UrlEncoded
    builder.use Faraday::Adapter::NetHttp
  end
end

#job(job_name) ⇒ Object



30
31
32
# File 'lib/jbcm.rb', line 30

def job(job_name)
  Jbcm::Client::Job.new(self, job_name)
end

#jobs(opts = {}) ⇒ Object



26
27
28
# File 'lib/jbcm.rb', line 26

def jobs(opts={})
  Jbcm::Client::Job.new(self).list(opts)
end