Class: Bugzilla::XMLRPC

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

Overview

Bugzilla::XMLRPC

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 443, path = '/xmlrpc.cgi', proxy_host = nil, proxy_port = nil, timeout = 60, http_basic_auth_user = nil, http_basic_auth_pass = nil) ⇒ XMLRPC

Bugzilla::XMLRPC#new(host, port = 443, path = ‘/xmlrpc.cgi’, proxy_host = nil, proxy_port = nil)



38
39
40
41
42
43
44
45
# File 'lib/bugzilla/xmlrpc.rb', line 38

def initialize(host, port = 443, path = '/xmlrpc.cgi', proxy_host = nil, proxy_port = nil, timeout = 60, http_basic_auth_user = nil, http_basic_auth_pass = nil)
  path ||= '/xmlrpc.cgi'
  use_ssl = port == 443 ? true : false
  @xmlrpc = ::XMLRPC::Client.new(host, path, port, proxy_host, proxy_port, http_basic_auth_user, http_basic_auth_pass, use_ssl, timeout)

  # workaround for https://bugs.ruby-lang.org/issues/8182
  @xmlrpc.http_header_extra = {'accept-encoding' => 'identity'}
end

Instance Method Details

#api_keyObject

Bugzilla::XMLRPC#api_key



108
109
110
# File 'lib/bugzilla/xmlrpc.rb', line 108

def api_key
  @api_key
end

#api_key=(val) ⇒ Object

Bugzilla::XMLRPC#api_key=(val)



118
119
120
# File 'lib/bugzilla/xmlrpc.rb', line 118

def api_key=(val)
  @api_key = val
end

#call(cmd, params = {}, user = nil, password = nil) ⇒ Object

Bugzilla::XMLRPC#call(cmd, params, user = nil, password = nil)



53
54
55
56
57
58
59
60
# File 'lib/bugzilla/xmlrpc.rb', line 53

def call(cmd, params = {}, user = nil, password = nil)
  params = {} if params.nil?
  params['Bugzilla_login'] = user unless user.nil? || password.nil?
  params['Bugzilla_password'] = password unless user.nil? || password.nil?
  params['Bugzilla_token'] = @token unless @token.nil?
  @xmlrpc.http_header_extra['Authorization'] = "Bearer #{@api_key}" unless @api_key.nil?
  @xmlrpc.call(cmd, params)
end

Bugzilla::XMLRPC#cookie



68
69
70
# File 'lib/bugzilla/xmlrpc.rb', line 68

def cookie
  @xmlrpc.cookie
end

#cookie=(val) ⇒ Object

Bugzilla::XMLRPC#cookie=(val)



78
79
80
# File 'lib/bugzilla/xmlrpc.rb', line 78

def cookie=(val)
  @xmlrpc.cookie = val
end

#tokenObject

Bugzilla::XMLRPC#token



88
89
90
# File 'lib/bugzilla/xmlrpc.rb', line 88

def token
  @token
end

#token=(val) ⇒ Object

Bugzilla::XMLRPC#token=(val)



98
99
100
# File 'lib/bugzilla/xmlrpc.rb', line 98

def token=(val)
  @token = val
end