rally_api 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,7 @@ module RallyAPI
|
|
29
29
|
@rally_http_client.send_timeout = 300
|
30
30
|
@rally_http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
31
31
|
@rally_http_client.transparent_gzip_decompression = true
|
32
|
+
#@rally_http_client.debug_dev = STDOUT
|
32
33
|
|
33
34
|
#passed in proxy setup overrides env level proxy
|
34
35
|
env_proxy = ENV["http_proxy"]
|
@@ -48,6 +49,23 @@ module RallyAPI
|
|
48
49
|
@rally_http_client.ssl_config.verify_mode = mode
|
49
50
|
end
|
50
51
|
|
52
|
+
#[]todo - handle token expiration more gracefully - eg handle renewing
|
53
|
+
def setup_security_token(security_url)
|
54
|
+
reset_cookies
|
55
|
+
begin
|
56
|
+
json_response = send_request(security_url, { :method => :get })
|
57
|
+
@security_token = json_response[json_response.keys[0]]["SecurityToken"]
|
58
|
+
rescue StandardError => ex
|
59
|
+
raise unless ex.message.include?("RallyAPI - HTTP-404") #for on-prem not on wsapi 2.x
|
60
|
+
end
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
#may be needed for session issues
|
65
|
+
def reset_cookies
|
66
|
+
@rally_http_client.cookie_manager.cookies = []
|
67
|
+
end
|
68
|
+
|
51
69
|
#you can have any number you want as long as it is between 1 and 4
|
52
70
|
def set_find_threads(num_threads = 2)
|
53
71
|
return if num_threads.class != Fixnum
|
@@ -88,10 +106,11 @@ module RallyAPI
|
|
88
106
|
end
|
89
107
|
|
90
108
|
#args should have :method
|
91
|
-
def send_request(url, args, url_params =
|
109
|
+
def send_request(url, args, url_params = {})
|
92
110
|
method = args[:method]
|
93
111
|
req_args = {}
|
94
|
-
|
112
|
+
url_params[:key] = @security_token unless @security_token.nil?
|
113
|
+
req_args[:query] = url_params if url_params.keys.length > 0
|
95
114
|
|
96
115
|
req_headers = @rally_headers.headers
|
97
116
|
if (args[:method] == :post) || (args[:method] == :put)
|
@@ -103,7 +122,7 @@ module RallyAPI
|
|
103
122
|
req_args[:header] = req_headers
|
104
123
|
|
105
124
|
begin
|
106
|
-
log_info("Rally API calling #{method} - #{url} with #{req_args}")
|
125
|
+
log_info("Rally API calling #{method} - #{url} with #{req_args}\n With cookies: #{@rally_http_client.cookie_manager.cookies}")
|
107
126
|
response = @rally_http_client.request(method, url, req_args)
|
108
127
|
rescue Exception => ex
|
109
128
|
msg = "RallyAPI: - rescued exception - #{ex.message} on request to #{url} with params #{url_params}"
|
@@ -113,7 +132,7 @@ module RallyAPI
|
|
113
132
|
|
114
133
|
log_info("RallyAPI response was - #{response.inspect}")
|
115
134
|
if response.status_code != 200
|
116
|
-
msg = "RallyAPI -
|
135
|
+
msg = "RallyAPI - HTTP-#{response.status_code} on request - #{url}."
|
117
136
|
msg << "\nResponse was: #{response.body}"
|
118
137
|
raise StandardError, msg
|
119
138
|
end
|
@@ -128,14 +147,14 @@ module RallyAPI
|
|
128
147
|
errors = []
|
129
148
|
warnings = []
|
130
149
|
if !result["OperationResult"].nil?
|
131
|
-
errors = result["OperationResult"]["Errors"]
|
132
|
-
warnings = result["OperationResult"]["Warnings"]
|
150
|
+
errors = result["OperationResult"]["Errors"] || []
|
151
|
+
warnings = result["OperationResult"]["Warnings"] || []
|
133
152
|
elsif !result["QueryResult"].nil?
|
134
|
-
errors = result["QueryResult"]["Errors"]
|
135
|
-
warnings = result["QueryResult"]["Warnings"]
|
153
|
+
errors = result["QueryResult"]["Errors"] || []
|
154
|
+
warnings = result["QueryResult"]["Warnings"] || []
|
136
155
|
elsif !result["CreateResult"].nil?
|
137
|
-
errors = result["CreateResult"]["Errors"]
|
138
|
-
warnings = result["CreateResult"]["Warnings"]
|
156
|
+
errors = result["CreateResult"]["Errors"] || []
|
157
|
+
warnings = result["CreateResult"]["Warnings"] || []
|
139
158
|
end
|
140
159
|
{:errors => errors, :warnings => warnings}
|
141
160
|
end
|
@@ -20,7 +20,7 @@ module RallyAPI
|
|
20
20
|
@warnings = warnings[:warnings]
|
21
21
|
end
|
22
22
|
|
23
|
-
def update(fields, params =
|
23
|
+
def update(fields, params = {})
|
24
24
|
oid = @rally_object["ObjectID"] || @rally_object["_ref"].split("/")[-1].split(".")[0]
|
25
25
|
@rally_object = @rally_rest.update(@type.downcase.to_sym, oid, fields, params).rally_object
|
26
26
|
end
|
@@ -30,8 +30,8 @@
|
|
30
30
|
module RallyAPI
|
31
31
|
|
32
32
|
#--
|
33
|
-
#
|
34
|
-
#expensive to query typedef and read all attributes for "OBJECT" or "COLLECTION" types
|
33
|
+
#This constant is here as a trade off of speed vs completeness- right now speed wins because it is so
|
34
|
+
#expensive to query typedef and read all attributes for "OBJECT" or "COLLECTION" types.
|
35
35
|
#++
|
36
36
|
RALLY_REF_FIELDS = { "Subscription" => :subscription, "Workspace" => :workspace, "Project" => :project,
|
37
37
|
"Iteration" => :iteration, "Release" => :release, "WorkProduct" => :artifact,
|
@@ -44,11 +44,11 @@ module RallyAPI
|
|
44
44
|
|
45
45
|
#Main Class to instantiate when using the tool
|
46
46
|
class RallyRestJson
|
47
|
-
DEFAULT_WSAPI_VERSION = "1.
|
47
|
+
DEFAULT_WSAPI_VERSION = "1.42"
|
48
48
|
|
49
|
-
attr_accessor :rally_url, :rally_user, :rally_password, :rally_workspace_name, :rally_project_name, :wsapi_version
|
50
|
-
|
51
|
-
|
49
|
+
attr_accessor :rally_url, :rally_user, :rally_password, :rally_workspace_name, :rally_project_name, :wsapi_version,
|
50
|
+
:rally_headers, :rally_default_workspace, :rally_default_project, :low_debug, :proxy_info,
|
51
|
+
:rally_rest_api_compat, :logger, :rally_alias_types
|
52
52
|
attr_reader :rally_connection
|
53
53
|
|
54
54
|
def initialize(args)
|
@@ -72,6 +72,7 @@ module RallyAPI
|
|
72
72
|
@rally_connection = RallyJsonConnection.new(@rally_headers, @low_debug, @proxy_info)
|
73
73
|
@rally_connection.set_client_user(@rally_url, @rally_user, @rally_password)
|
74
74
|
@rally_connection.logger = @logger unless @logger.nil?
|
75
|
+
@rally_connection.setup_security_token(security_url)
|
75
76
|
|
76
77
|
if !@rally_workspace_name.nil?
|
77
78
|
@rally_default_workspace = find_workspace(@rally_workspace_name)
|
@@ -133,7 +134,6 @@ module RallyAPI
|
|
133
134
|
RallyObject.new(self, json_response[rally_type], warnings(json_response))
|
134
135
|
end
|
135
136
|
|
136
|
-
|
137
137
|
def create(type, fields, params = {})
|
138
138
|
type = check_type(type)
|
139
139
|
if (fields["Workspace"].nil? && fields["Project"].nil?)
|
@@ -183,7 +183,7 @@ module RallyAPI
|
|
183
183
|
json_response[rally_type]
|
184
184
|
end
|
185
185
|
|
186
|
-
def update(type, obj_id, fields, params =
|
186
|
+
def update(type, obj_id, fields, params = {})
|
187
187
|
type = check_type(type)
|
188
188
|
ref = check_id(type.to_s, obj_id)
|
189
189
|
fields = RallyAPI::RallyRestJson.fix_case(fields) if @rally_rest_api_compat
|
@@ -322,6 +322,10 @@ module RallyAPI
|
|
322
322
|
"#{@rally_url}/webservice/#{@wsapi_version}/#{type}.js"
|
323
323
|
end
|
324
324
|
|
325
|
+
def security_url
|
326
|
+
"#{@rally_url}/webservice/#{@wsapi_version}/security/authorize.js"
|
327
|
+
end
|
328
|
+
|
325
329
|
def make_read_url(type,oid)
|
326
330
|
"#{@rally_url}/webservice/#{@wsapi_version}/#{type}/#{oid}.js"
|
327
331
|
end
|
data/lib/rally_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rally_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
16
|
-
requirement: &
|
16
|
+
requirement: &70292743604960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.2.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70292743604960
|
25
25
|
description: API wrapper for Rally's JSON REST web services api
|
26
26
|
email:
|
27
27
|
- dsmith@rallydev.com
|