Class: ALM::RestConnector

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/alm-rest-api/rest-connector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



11
12
13
# File 'lib/alm-rest-api/rest-connector.rb', line 11

def cookies
  @cookies
end

#domainObject

Returns the value of attribute domain.



14
15
16
# File 'lib/alm-rest-api/rest-connector.rb', line 14

def domain
  @domain
end

#hostObject

Returns the value of attribute host.



12
13
14
# File 'lib/alm-rest-api/rest-connector.rb', line 12

def host
  @host
end

#portObject

Returns the value of attribute port.



13
14
15
# File 'lib/alm-rest-api/rest-connector.rb', line 13

def port
  @port
end

#projectObject

Returns the value of attribute project.



15
16
17
# File 'lib/alm-rest-api/rest-connector.rb', line 15

def project
  @project
end

Instance Method Details

#buildDefectUrl(defectId) ⇒ Object



29
30
31
# File 'lib/alm-rest-api/rest-connector.rb', line 29

def buildDefectUrl(defectId)
  return buildUrl('qcbin/rest/domains/' + domain + '/projects/' + project + '/defects/' + defectId)
end

#buildEntityCollectionUrl(entityType) ⇒ Object



25
26
27
# File 'lib/alm-rest-api/rest-connector.rb', line 25

def buildEntityCollectionUrl(entityType)
  return buildUrl('qcbin/rest/domains/' + domain + '/projects/' + project + '/' + entityType + 's')
end

#buildUrl(path) ⇒ Object



33
34
35
# File 'lib/alm-rest-api/rest-connector.rb', line 33

def buildUrl(path)
  return "http://#{host}:#{port}/#{path}"
end

#getCookieStringObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/alm-rest-api/rest-connector.rb', line 58

def getCookieString
  s = StringIO.new
  if (!cookies.empty?)
    cookies.each{|key,value|
      s << key << '=' << value << ';'
    }
  end

  return s.string
end

#httpBasicAuth(url, username, password) ⇒ Object



53
54
55
56
# File 'lib/alm-rest-api/rest-connector.rb', line 53

def httpBasicAuth(url, username, password)
  headers = {"username" => username, "password" => password}
  return doHttp('AUTH', url, nil, nil, headers, cookies)    
end

#httpDelete(url, headers) ⇒ Object



45
46
47
# File 'lib/alm-rest-api/rest-connector.rb', line 45

def httpDelete(url, headers)
  return doHttp('DELETE', url, nil, nil, headers, cookies)
end

#httpGet(url, queryString, headers) ⇒ Object



49
50
51
# File 'lib/alm-rest-api/rest-connector.rb', line 49

def httpGet(url, queryString, headers)
  return doHttp('GET', url, queryString, nil, headers, cookies)
end

#httpPost(url, data, headers) ⇒ Object



41
42
43
# File 'lib/alm-rest-api/rest-connector.rb', line 41

def httpPost(url, data, headers)
  return doHttp('POST', url, nil, data, headers, cookies)
end

#httpPut(url, data, headers) ⇒ Object



37
38
39
# File 'lib/alm-rest-api/rest-connector.rb', line 37

def httpPut(url, data, headers)
  return doHttp('PUT', url, nil, data, headers, cookies)
end

#init(cookies, host, port, domain, project) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/alm-rest-api/rest-connector.rb', line 17

def init(cookies, host, port, domain, project)
  @cookies = cookies
  @host = host
  @port = port
  @domain = domain
  @project = project
end