Class: ALM::RestConnector
- Inherits:
-
Object
- Object
- ALM::RestConnector
- Includes:
- Singleton
- Defined in:
- lib/alm-rest-api/rest-connector.rb
Instance Attribute Summary collapse
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
- #buildDefectUrl(defectId) ⇒ Object
- #buildEntityCollectionUrl(entityType) ⇒ Object
- #buildUrl(path) ⇒ Object
- #getCookieString ⇒ Object
- #httpBasicAuth(url, username, password) ⇒ Object
- #httpDelete(url, headers) ⇒ Object
- #httpGet(url, queryString, headers) ⇒ Object
- #httpPost(url, data, headers) ⇒ Object
- #httpPut(url, data, headers) ⇒ Object
- #init(cookies, host, port, domain, project) ⇒ Object
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies.
11 12 13 |
# File 'lib/alm-rest-api/rest-connector.rb', line 11 def @cookies end |
#domain ⇒ Object
Returns the value of attribute domain.
14 15 16 |
# File 'lib/alm-rest-api/rest-connector.rb', line 14 def domain @domain end |
#host ⇒ Object
Returns the value of attribute host.
12 13 14 |
# File 'lib/alm-rest-api/rest-connector.rb', line 12 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
13 14 15 |
# File 'lib/alm-rest-api/rest-connector.rb', line 13 def port @port end |
#project ⇒ Object
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 |
#getCookieString ⇒ Object
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 (!.empty?) .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, ) 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, ) 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, ) 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, ) 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, ) 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(, host, port, domain, project) @cookies = @host = host @port = port @domain = domain @project = project end |