rally_api 0.8.1 → 0.8.2
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.
- data/lib/rally_api/rally_object.rb +1 -1
- data/lib/rally_api/rally_query.rb +2 -6
- data/lib/rally_api/rally_rest_json.rb +34 -55
- data/lib/rally_api/version.rb +1 -1
- metadata +4 -4
@@ -51,10 +51,10 @@ module RallyAPI
|
|
51
51
|
query_params
|
52
52
|
end
|
53
53
|
|
54
|
-
def validate(
|
54
|
+
def validate()
|
55
55
|
errors = []
|
56
56
|
|
57
|
-
if @type.nil?
|
57
|
+
if @type.nil? || type == ""
|
58
58
|
errors.push("Object type for query cannot be nil")
|
59
59
|
end
|
60
60
|
|
@@ -74,10 +74,6 @@ module RallyAPI
|
|
74
74
|
errors.push("Project - #{@project} - must have a ref") if @project["_ref"].nil?
|
75
75
|
end
|
76
76
|
|
77
|
-
if (allowed_objects[@type.to_s].nil?)
|
78
|
-
errors.push( "Object Type #{@type} is not query-able: inspect RallyRestJson.rally_objects for allowed types" )
|
79
|
-
end
|
80
|
-
|
81
77
|
errors
|
82
78
|
end
|
83
79
|
|
@@ -30,7 +30,7 @@
|
|
30
30
|
module RallyAPI
|
31
31
|
|
32
32
|
#--
|
33
|
-
#this contstant is here
|
33
|
+
#this contstant is here as a tradeoff of speed vs completeness- right now speed wins because it is so
|
34
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,
|
@@ -44,15 +44,17 @@ 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.39"
|
48
48
|
|
49
49
|
attr_accessor :rally_url, :rally_user, :rally_password, :rally_workspace_name, :rally_project_name, :wsapi_version
|
50
50
|
attr_accessor :rally_headers, :rally_default_workspace, :rally_default_project, :low_debug, :proxy_info
|
51
|
-
attr_accessor :rally_rest_api_compat, :logger
|
51
|
+
attr_accessor :rally_rest_api_compat, :logger, :rally_alias_types
|
52
52
|
|
53
|
-
attr_reader :rally_connection
|
53
|
+
attr_reader :rally_connection
|
54
54
|
|
55
55
|
def initialize(args)
|
56
|
+
@rally_alias_types = { "story" => "HierarchicalRequirement", "userstory" => "HierarchicalRequirement" }
|
57
|
+
|
56
58
|
@rally_url = args[:base_url] || "https://rally1.rallydev.com/slm"
|
57
59
|
@rally_user = args[:username]
|
58
60
|
@rally_password = args[:password]
|
@@ -62,6 +64,7 @@ module RallyAPI
|
|
62
64
|
@rally_headers = args[:headers] || CustomHttpHeader.new
|
63
65
|
@proxy_info = args[:proxy]
|
64
66
|
|
67
|
+
#flag to help RallyRestAPI users to use snake case field names eg Defect.fixed_in_build vs Defect["FixedInBuild"]
|
65
68
|
@rally_rest_api_compat = args[:rally_rest_api_compat] || false
|
66
69
|
|
67
70
|
@low_debug = args[:debug] || false
|
@@ -71,16 +74,11 @@ module RallyAPI
|
|
71
74
|
@rally_connection.set_client_user(@rally_url, @rally_user, @rally_password)
|
72
75
|
@rally_connection.logger = @logger unless @logger.nil?
|
73
76
|
|
74
|
-
@rally_objects = { "typedefinition" => "TypeDefinition", "user" => "User", "subscription" => "Subscription",
|
75
|
-
"workspace" => "Workspace", "project" => "Project" }
|
76
|
-
|
77
77
|
if !@rally_workspace_name.nil?
|
78
78
|
@rally_default_workspace = find_workspace(@rally_workspace_name)
|
79
79
|
raise StandardError, "unable to find default workspace #{@rally_workspace_name}" if @rally_default_workspace.nil?
|
80
80
|
end
|
81
81
|
|
82
|
-
cache_rally_objects()
|
83
|
-
|
84
82
|
if !@rally_project_name.nil?
|
85
83
|
@rally_default_project = find_project(@rally_default_workspace, @rally_project_name)
|
86
84
|
raise StandardError, "unable to find default project #{@rally_project_name}" if @rally_default_project.nil?
|
@@ -131,34 +129,37 @@ module RallyAPI
|
|
131
129
|
|
132
130
|
def user
|
133
131
|
args = { :method => :get }
|
134
|
-
json_response = @rally_connection.send_request(make_get_url(
|
132
|
+
json_response = @rally_connection.send_request(make_get_url("user"), args)
|
135
133
|
rally_type = json_response.keys[0]
|
136
134
|
RallyObject.new(self, json_response[rally_type])
|
137
135
|
end
|
138
136
|
|
139
137
|
|
140
138
|
def create(type, fields)
|
141
|
-
|
142
|
-
|
139
|
+
type = check_type(type)
|
143
140
|
if (fields["Workspace"].nil? && fields["Project"].nil?)
|
144
141
|
fields["Workspace"] = @rally_default_workspace._ref unless @rally_default_workspace.nil?
|
145
142
|
fields["Project"] = @rally_default_project._ref unless @rally_default_project.nil?
|
146
143
|
end
|
147
144
|
|
148
|
-
|
145
|
+
ws_ref = fields["Workspace"]
|
146
|
+
ws_ref = ws_ref["_ref"] unless ws_ref.class == String
|
147
|
+
params = { :workspace => ws_ref }
|
148
|
+
|
149
|
+
object2create = { type => make_ref_fields(fields) }
|
149
150
|
args = { :method => :post, :payload => object2create }
|
150
151
|
#json_response = @rally_connection.create_object(make_create_url(rally_type), args, object2create)
|
151
|
-
json_response = @rally_connection.send_request(make_create_url(
|
152
|
+
json_response = @rally_connection.send_request(make_create_url(type), args, params)
|
152
153
|
#todo - check for warnings
|
153
154
|
RallyObject.new(self, json_response["CreateResult"]["Object"]).read()
|
154
155
|
end
|
155
156
|
|
156
157
|
|
157
|
-
def read(type, obj_id, params =
|
158
|
-
|
159
|
-
ref = check_id(
|
158
|
+
def read(type, obj_id, params = {})
|
159
|
+
type = check_type(type)
|
160
|
+
ref = check_id(type.to_s, obj_id)
|
161
|
+
params[:workspace] = @rally_default_workspace.ref if params[:workspace].nil?
|
160
162
|
args = { :method => :get }
|
161
|
-
#json_response = @rally_connection.read_object(ref, args, params)
|
162
163
|
json_response = @rally_connection.send_request(ref, args, params)
|
163
164
|
rally_type = json_response.keys[0]
|
164
165
|
RallyObject.new(self, json_response[rally_type])
|
@@ -171,8 +172,11 @@ module RallyAPI
|
|
171
172
|
json_response["OperationResult"]
|
172
173
|
end
|
173
174
|
|
174
|
-
def reread(json_object, params =
|
175
|
+
def reread(json_object, params = {})
|
175
176
|
args = { :method => :get }
|
177
|
+
if params[:workspace].nil? && (json_object["Workspace"] && json_object["Workspace"]["_ref"])
|
178
|
+
params[:workspace] = json_object['Workspace']['_ref']
|
179
|
+
end
|
176
180
|
#json_response = @rally_connection.read_object(json_object["_ref"], args, params)
|
177
181
|
json_response = @rally_connection.send_request(json_object["_ref"], args, params)
|
178
182
|
rally_type = json_response.keys[0]
|
@@ -181,9 +185,9 @@ module RallyAPI
|
|
181
185
|
|
182
186
|
|
183
187
|
def update(type, obj_id, fields)
|
184
|
-
|
185
|
-
ref = check_id(
|
186
|
-
json_update = {
|
188
|
+
type = check_type(type)
|
189
|
+
ref = check_id(type.to_s, obj_id)
|
190
|
+
json_update = { type.to_s => make_ref_fields(fields) }
|
187
191
|
args = { :method => :post, :payload => json_update }
|
188
192
|
#json_response = @rally_connection.update_object(ref, args, json_update)
|
189
193
|
json_response = @rally_connection.send_request(ref, args)
|
@@ -222,12 +226,12 @@ module RallyAPI
|
|
222
226
|
query_obj.workspace = @rally_default_workspace unless @rally_default_workspace.nil?
|
223
227
|
end
|
224
228
|
|
225
|
-
errs = query_obj.validate(
|
229
|
+
errs = query_obj.validate()
|
226
230
|
if errs.length > 0
|
227
231
|
raise StandardError, "Errors making Rally Query: #{errs.to_s}"
|
228
232
|
end
|
229
233
|
|
230
|
-
query_url = make_query_url(@rally_url, @wsapi_version, check_type(query_obj.type))
|
234
|
+
query_url = make_query_url(@rally_url, @wsapi_version, check_type(query_obj.type.to_s))
|
231
235
|
query_params = query_obj.make_query_params
|
232
236
|
args = {:user => @rally_user, :password => @rally_password}
|
233
237
|
json_response = @rally_connection.get_all_json_results(query_url, args, query_params, query_obj.limit)
|
@@ -277,7 +281,7 @@ module RallyAPI
|
|
277
281
|
|
278
282
|
def get_typedef_for(type)
|
279
283
|
type = type.to_s if type.class == Symbol
|
280
|
-
type =
|
284
|
+
type = check_type(type)
|
281
285
|
type_def_query = RallyQuery.new()
|
282
286
|
type_def_query.type = "typedefinition"
|
283
287
|
type_def_query.fetch = true
|
@@ -335,12 +339,12 @@ module RallyAPI
|
|
335
339
|
"/#{ref_pieces[-2]}/#{ref_pieces[-1].split(".js")[0]}"
|
336
340
|
end
|
337
341
|
|
342
|
+
#check for an alias of a type - eg userstory => hierarchicalrequirement
|
343
|
+
#you can add to @rally_alias_types as desired
|
338
344
|
def check_type(type_name)
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
end
|
343
|
-
type.gsub(" ", "") #for wsapi no space is expected
|
345
|
+
alias_name = @rally_alias_types[type_name.downcase.to_s]
|
346
|
+
return alias_name unless alias_name.nil?
|
347
|
+
return type_name
|
344
348
|
end
|
345
349
|
|
346
350
|
#ref should be like https://rally1.rallydev.com/slm/webservice/1.25/defect/12345.js
|
@@ -391,31 +395,6 @@ module RallyAPI
|
|
391
395
|
fields
|
392
396
|
end
|
393
397
|
|
394
|
-
def cache_rally_objects()
|
395
|
-
type_defs_query = RallyQuery.new()
|
396
|
-
type_defs_query.type = "typedefinition"
|
397
|
-
type_defs_query.fetch = "Name,Parent,ElementName,TypePath"
|
398
|
-
type_defs_query.workspace = @rally_default_workspace unless @rally_default_workspace.nil?
|
399
|
-
|
400
|
-
type_defs = find(type_defs_query)
|
401
|
-
type_defs.each do |td|
|
402
|
-
url_path = td.TypePath.nil? ? td.ElementName : td.TypePath
|
403
|
-
@rally_objects[url_path.downcase] = url_path
|
404
|
-
|
405
|
-
parent_type = td.Parent
|
406
|
-
if !parent_type.nil? && (@rally_objects[parent_type.TypePath].nil?)
|
407
|
-
url_path = parent_type.TypePath.nil? ? parent_type.ElementName : parent_type.TypePath
|
408
|
-
@rally_objects[url_path.downcase] = url_path
|
409
|
-
end
|
410
|
-
end
|
411
|
-
|
412
|
-
#some convenience keys to help people - someday we'll fix the api and make HR called story
|
413
|
-
@rally_objects["useriterationcapacity"] = "User Iteration Capacity"
|
414
|
-
@rally_objects["userpermission"] = "User Permission"
|
415
|
-
@rally_objects["story"] = "Hierarchical Requirement"
|
416
|
-
@rally_objects["userstory"] = "Hierarchical Requirement"
|
417
|
-
end
|
418
|
-
|
419
398
|
end
|
420
399
|
|
421
400
|
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.8.
|
4
|
+
version: 0.8.2
|
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:
|
12
|
+
date: 2013-01-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
16
|
-
requirement: &
|
16
|
+
requirement: &70193372021960 !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: *70193372021960
|
25
25
|
description: API wrapper for Rally's JSON REST web services api
|
26
26
|
email:
|
27
27
|
- dsmith@rallydev.com
|