rally_api 1.1.2 → 1.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50040c40bf7a8cd382eba81d0c0a42330546dfcf
4
- data.tar.gz: 330a379e16d4b3d84079267d16f1e2344db732cc
3
+ metadata.gz: 330bb4339cde6317ad030f5a9db668b3efa37604
4
+ data.tar.gz: 538376f2077a0ba28b57def35ddc9bc7bf667cc2
5
5
  SHA512:
6
- metadata.gz: bdec386d5e21e0b510a5da11aa3b3f5541f772826d08a04fc20ae7d04da6479e6878f33c602534733cdd0456fce90540b6aceecb22b84fee87a8c075b4ff5903
7
- data.tar.gz: 70d189c7610e6c4d11caec1b68c4333101640d1bca5da3d4c27179fd1c62f1c13bfbc293825bd808037f10280acfa9d7852bed314fa13a1e3691f1b6ba487e89
6
+ metadata.gz: bd3a8bd2011162e285f2ec2822d86f207460e1d55a18d7be5ae6337ccdb487f69506a640af2e579e412ea2ba6bd5cb13a4c6f01f0281fc514ce1f0d171cf7fb8
7
+ data.tar.gz: b14a2ca16e3762eb8e3e9c001aff81ef10c374096976860812cce14d128a07e8a1ee9ec838f385c74094ad81af65b015ddcc3b686bbe82844cd7b9c6b7933b58
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## License
2
2
 
3
- Copyright (c) Rally Software Development Corp. 2013 Distributed under the MIT License.
3
+ Copyright (c) Rally Software Development Corp. 2015 Distributed under the MIT License.
4
4
 
5
5
  ## Warranty
6
6
 
@@ -16,7 +16,7 @@ RallyAPI (rally_api) -- a wrapper for Rally's REST Web Services API
16
16
 
17
17
  [![Stories in Ready](http://badge.waffle.io/RallyTools/RallyRestToolkitForRuby.png)](http://waffle.io/RallyTools/RallyRestToolkitForRuby)
18
18
 
19
- RallyAPI is a wrapper of Rally's Web Service API Json endpoints using rest-client and native json parsing
19
+ RallyAPI is a wrapper of Rally's Web Service API JSON endpoints using rest-client and native json parsing
20
20
  Check the examples directory for more detailed samples.
21
21
 
22
22
  ### Installation
@@ -70,8 +70,8 @@ A Rally API Key can be used for user authentication. If an API Key is provided,
70
70
  test_query = RallyAPI::RallyQuery.new()
71
71
  test_query.type = "defect"
72
72
  test_query.fetch = "Name"
73
- test_query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.25/workspace/12345.js" } #optional
74
- test_query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.25/project/12345.js" } #optional
73
+ test_query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/12345" } #optional
74
+ test_query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/12345" } #optional
75
75
  test_query.page_size = 200 #optional - default is 200
76
76
  test_query.limit = 1000 #optional - default is 99999
77
77
  test_query.project_scope_up = false
@@ -114,8 +114,8 @@ A Rally API Key can be used for user authentication. If an API Key is provided,
114
114
  #If you query with a specific fetch string, for example query defect and fetch Name,Severity,Description
115
115
  #You will *only* get back those fields defect.Priority will be nil, but may not be null in Rally
116
116
  #Use object.read or @rally.read to make sure you read the whole object if you want what is in Rally
117
- # This is done for speed - lazy loading (going back to get a value from Rally) can be unneccessarily slow
118
- # *Pick you fetch strings wisely* fetch everything you need and don't rely on read if you don't need it the speed is worth it.
117
+ # This is done for speed - lazy loading (going back to get a value from Rally) can be unnecessarily slow
118
+ # *Pick your fetch strings wisely* fetch everything you need and don't rely on read if you don't need it, the speed is worth it.
119
119
 
120
120
  ### Creating an Artifact
121
121
  obj = {}
@@ -147,10 +147,16 @@ A Rally API Key can be used for user authentication. If an API Key is provided,
147
147
  story1.rank_to_top
148
148
 
149
149
  ### Revision History
150
+
151
+ Version 1.2.0 (April 2015) - set default WSAPI version to 2.0, fix paging issue in reread,
152
+ can now use DisplayName for custom fields in create and update operations.
153
+ Set httpclient gem runtime dependency to '= 2.5.0'.
154
+
155
+ Version 1.1.2 (October 2014) - Set httpclient gem runtime dependency to '~> 2.4.0'.
156
+
157
+ Version 1.1.1 (October 2014) - Relax httpclient gem runtime dependency to '>= 2.3.0'.
158
+
150
159
  Version 1.1.0 (September 2014) - Appends workspace to Rally API requests to enable correct retrieval
151
160
  of allowed values from a user's non-default workspace. Updates gem development dependencies and
152
161
  test files structure.
153
162
 
154
- Version 1.1.1 (October 2014) - Relax version requirement of httpclient runtime
155
- dependency to '>= 2.3.0'.
156
-
@@ -1,4 +1,4 @@
1
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
1
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
2
2
  #Your use of this Software is governed by the terms and conditions
3
3
  #of the applicable Subscription Agreement between your company and
4
4
  #Rally Software Development Corp.
@@ -1,4 +1,4 @@
1
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
1
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
2
2
  #Your use of this Software is governed by the terms and conditions
3
3
  #of the applicable Subscription Agreement between your company and
4
4
  #Rally Software Development Corp.
@@ -1,5 +1,5 @@
1
1
  # :stopdoc:
2
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
2
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
3
3
  #Your use of this Software is governed by the terms and conditions
4
4
  #of the applicable Subscription Agreement between your company and
5
5
  #Rally Software Development Corp.
@@ -1,5 +1,5 @@
1
1
  # :stopdoc:
2
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
2
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
3
3
  #Your use of this Software is governed by the terms and conditions
4
4
  #of the applicable Subscription Agreement between your company and
5
5
  #Rally Software Development Corp.
@@ -2,7 +2,7 @@ require "httpclient"
2
2
  require 'json'
3
3
 
4
4
  # :stopdoc:
5
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
5
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
6
6
  #Your use of this Software is governed by the terms and conditions
7
7
  #of the applicable Subscription Agreement between your company and
8
8
  #Rally Software Development Corp.
@@ -1,5 +1,5 @@
1
1
  # :stopdoc:
2
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
2
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
3
3
  #Your use of this Software is governed by the terms and conditions
4
4
  #of the applicable Subscription Agreement between your company and
5
5
  #Rally Software Development Corp.
@@ -15,14 +15,15 @@ module RallyAPI
15
15
 
16
16
  def initialize(rally_rest, json_hash, warnings = {})
17
17
  # handle that we might not get a _ref or a _type
18
- if !json_hash["_type"].nil? || !json_hash["_ref"].nil?
19
- @type = json_hash["_type"] || json_hash["_ref"].split("/")[-2]
20
- else
21
- @type = "unknown"
22
- end
18
+ @type = "unknown"
19
+ if json_hash["_type"] && !json_hash["_type"].empty?
20
+ @type = json_hash["_type"]
21
+ elsif json_hash["_ref"] && !json_hash["_ref"].empty?
22
+ @type = json_hash["_ref"].split("/")[-2]
23
+ end
23
24
  @rally_object = json_hash
24
- @rally_rest = rally_rest
25
- @warnings = warnings[:warnings]
25
+ @rally_rest = rally_rest
26
+ @warnings = warnings[:warnings]
26
27
  end
27
28
 
28
29
  def update(fields, params = {})
@@ -150,21 +151,6 @@ module RallyAPI
150
151
  ret_val
151
152
  end
152
153
 
153
- #def get_val(field)
154
- # return_val = rally_object[field]
155
- #
156
- # if return_val.class == Hash
157
- # return RallyObject.new(@rally_rest, return_val)
158
- # end
159
- #
160
- # if return_val.class == Array
161
- # make_object_array(field)
162
- # return_val = rally_object[field]
163
- # end
164
- #
165
- # return_val
166
- #end
167
-
168
154
  def get_val(field)
169
155
  return_val = @rally_object[field]
170
156
  return_val = @rally_object["c_#{field}"] if return_val.nil?
@@ -1,5 +1,5 @@
1
1
  # :stopdoc:
2
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
2
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
3
3
  #Your use of this Software is governed by the terms and conditions
4
4
  #of the applicable Subscription Agreement between your company and
5
5
  #Rally Software Development Corp.
@@ -1,5 +1,5 @@
1
1
  # :stopdoc:
2
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
2
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
3
3
  #Your use of this Software is governed by the terms and conditions
4
4
  #of the applicable Subscription Agreement between your company and
5
5
  #Rally Software Development Corp.
@@ -5,7 +5,7 @@
5
5
  #require "rally_query_result"
6
6
 
7
7
  # --
8
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
8
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
9
9
  #Your use of this Software is governed by the terms and conditions
10
10
  #of the applicable Subscription Agreement between your company and
11
11
  #Rally Software Development Corp.
@@ -44,7 +44,7 @@ module RallyAPI
44
44
 
45
45
  #Main Class to instantiate when using the tool
46
46
  class RallyRestJson
47
- DEFAULT_WSAPI_VERSION = "1.43"
47
+ DEFAULT_WSAPI_VERSION = "v2.0"
48
48
 
49
49
  attr_accessor :rally_url, :rally_workspace_name, :rally_project_name, :wsapi_version,
50
50
  :rally_headers, :rally_default_workspace, :rally_default_project, :low_debug, :proxy_info,
@@ -96,12 +96,13 @@ module RallyAPI
96
96
  end
97
97
 
98
98
  def send_request(url = nil, args = nil, params = {})
99
+ url += '.js' if @wsapi_version !~ /^v2/ && url !~ /\.js$/ # append ".js" if it is needed
99
100
  if params[:workspace].nil? && rally_workspace_object
100
101
  params[:workspace] = rally_workspace_object['_ref']
101
102
  end
102
103
  if params[:workspace]
103
104
  wksp_id = params[:workspace].match(/workspace\/(\d*)/)[1]
104
- url += "?/workspace=/workspace/#{wksp_id}"
105
+ url += "?workspace=workspace/#{wksp_id}"
105
106
  end
106
107
  @rally_connection.send_request(url, args, params)
107
108
  end
@@ -181,15 +182,15 @@ module RallyAPI
181
182
  params[:workspace] = ws_ref
182
183
 
183
184
  fields = RallyAPI::RallyRestJson.fix_case(fields) if @rally_rest_api_compat
184
- object2create = { type => check_fields(fields) }
185
+ postable_fields = check_fields(fields)
186
+ postable_fields = adjust_for_custom(type, postable_fields) if @wsapi_version =~ /^v2/
187
+ object2create = { type => postable_fields }
185
188
  args = { :method => :post, :payload => object2create }
186
- #json_response = @rally_connection.create_object(make_create_url(rally_type), args, object2create)
187
189
  json_response = send_request(make_create_url(type), args, params)
188
190
  #todo - check for warnings
189
191
  RallyObject.new(self, json_response["CreateResult"]["Object"], warnings(json_response)).read()
190
192
  end
191
193
 
192
-
193
194
  def read(type, obj_id, params = {})
194
195
  type = check_type(type)
195
196
  ref = check_id(type.to_s, obj_id)
@@ -224,7 +225,7 @@ module RallyAPI
224
225
  pagesize = params[:pagesize] || 200
225
226
  full_collection = []
226
227
  start.step(collection_count, pagesize).each do |page_start|
227
- page = reread(collection_hash, {:pagesize => 200, :startindex => page_start})
228
+ page = reread(collection_hash, {:pagesize => 200, :start => page_start})
228
229
  full_collection.concat(page["Results"])
229
230
  end
230
231
  {"Results" => full_collection}
@@ -234,7 +235,9 @@ module RallyAPI
234
235
  type = check_type(type)
235
236
  ref = check_id(type.to_s, obj_id)
236
237
  fields = RallyAPI::RallyRestJson.fix_case(fields) if @rally_rest_api_compat
237
- json_update = {type.to_s => check_fields(fields)}
238
+ update_fields = check_fields(fields)
239
+ update_fields = adjust_for_custom(type.to_s, update_fields) if @wsapi_version =~ /^v2/
240
+ json_update = {type.to_s => update_fields}
238
241
  args = {:method => :post, :payload => json_update}
239
242
  json_response = send_request(ref, args, params)
240
243
  #todo check for warnings on json_response["OperationResult"]
@@ -247,8 +250,8 @@ module RallyAPI
247
250
  #test_query = RallyAPI::RallyQuery.new()
248
251
  #test_query.type = :defect
249
252
  #test_query.fetch = "Name"
250
- #test_query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.25/workspace/12345.js" } #optional
251
- #test_query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/1.25/project/12345.js" } #optional
253
+ #test_query.workspace = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/workspace/12345" } #optional
254
+ #test_query.project = {"_ref" => "https://rally1.rallydev.com/slm/webservice/v2.0/project/12345" } #optional
252
255
  #test_query.page_size = 200 #optional - default is 200
253
256
  #test_query.limit = 1000 #optional - default is 99999
254
257
  #test_query.project_scope_up = false
@@ -279,6 +282,7 @@ module RallyAPI
279
282
  end
280
283
 
281
284
  query_url = make_query_url(@rally_url, @wsapi_version, check_type(query_obj.type.to_s))
285
+ query_url += '.js' if @wsapi_version !~ /^v2/
282
286
  query_params = query_obj.make_query_params
283
287
  args = {:method => :get}
284
288
  json_response = @rally_connection.get_all_json_results(query_url, args, query_params, query_obj.limit)
@@ -290,7 +294,7 @@ module RallyAPI
290
294
  end
291
295
 
292
296
  #rankAbove=%2Fhierarchicalrequirement%2F4624552599
293
- #{"hierarchicalrequirement":{"_ref":"https://rally1.rallydev.com/slm/webservice/1.27/hierarchicalrequirement/4616818613.js"}}
297
+ #{"hierarchicalrequirement":{"_ref":"https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement/4616818613"}}
294
298
  def rank_above(ref_to_rank, relative_ref)
295
299
  ref = ref_to_rank
296
300
  params = {}
@@ -389,28 +393,33 @@ module RallyAPI
389
393
  end
390
394
 
391
395
  def make_get_url(type)
392
- "#{@rally_url}/webservice/#{@wsapi_version}/#{type}.js"
396
+ "#{@rally_url}/webservice/#{@wsapi_version}/#{type}"
393
397
  end
394
398
 
395
399
  def security_url
396
- "#{@rally_url}/webservice/#{@wsapi_version}/security/authorize.js"
400
+ "#{@rally_url}/webservice/#{@wsapi_version}/security/authorize"
397
401
  end
398
402
 
399
403
  def make_read_url(type,oid)
400
- "#{@rally_url}/webservice/#{@wsapi_version}/#{type}/#{oid}.js"
404
+ "#{@rally_url}/webservice/#{@wsapi_version}/#{type}/#{oid}"
401
405
  end
402
406
 
403
407
  def make_create_url(type)
404
- "#{@rally_url}/webservice/#{@wsapi_version}/#{type}/create.js"
408
+ "#{@rally_url}/webservice/#{@wsapi_version}/#{type}/create"
405
409
  end
406
410
 
407
411
  def make_query_url(rally_url, wsapi_version, type)
408
- "#{rally_url}/webservice/#{wsapi_version}/#{type}.js"
412
+ "#{rally_url}/webservice/#{wsapi_version}/#{type}"
409
413
  end
410
414
 
411
415
  def short_ref(long_ref)
412
- ref_pieces = long_ref.split("/")
413
- "/#{ref_pieces[-2]}/#{ref_pieces[-1].split(".js")[0]}"
416
+ if @wsapi_version =~ /^v2/
417
+ path_components = long_ref.split("/")
418
+ path_components[-2..-1].join("/")
419
+ else
420
+ ref_pieces = long_ref.split("/")
421
+ "/#{ref_pieces[-2]}/#{ref_pieces[-1].split(".js")[0]}"
422
+ end
414
423
  end
415
424
 
416
425
  def warnings(json_obj)
@@ -425,12 +434,16 @@ module RallyAPI
425
434
  return type_name
426
435
  end
427
436
 
428
- #ref should be like https://rally1.rallydev.com/slm/webservice/1.25/defect/12345.js
437
+ #ref should be like https://rally1.rallydev.com/slm/webservice/v2.0/defect/12345
429
438
  def has_ref?(json_object)
430
439
  if json_object["_ref"].nil?
431
440
  return false
432
441
  end
433
- return true if json_object["_ref"] =~ /^https:\/\/\S*(\/slm\/webservice)\S*.js$/
442
+ if @wsapi_version =~ /^v2/
443
+ return true if json_object["_ref"] =~ /^https:\/\/\S*(\/slm\/webservice)\S*$/
444
+ else
445
+ return true if json_object["_ref"] =~ /^https:\/\/\S*(\/slm\/webservice)\S*.js$/
446
+ end
434
447
  false
435
448
  end
436
449
 
@@ -460,7 +473,7 @@ module RallyAPI
460
473
  nil
461
474
  end
462
475
 
463
- #eg https://rally1.rallydev.com/slm/webservice/1.25/defect/12345.js
476
+ #eg https://rally1.rallydev.com/slm/webservice/v2.0/defect/12345
464
477
  def get_type_from_ref(ref)
465
478
  ref.split("/")[-2]
466
479
  end
@@ -468,6 +481,7 @@ module RallyAPI
468
481
  def check_fields(fields)
469
482
  fields.each do |key, val|
470
483
  fields[key] = make_ref_field(val)
484
+
471
485
  if val.class == Time
472
486
  fields[key] = val.iso8601
473
487
  end
@@ -493,6 +507,25 @@ module RallyAPI
493
507
  val
494
508
  end
495
509
 
510
+ def adjust_for_custom(type, fields)
511
+ # only needed for when using WSAPI v2.x or later, custom fields must be prefixed with 'c_'
512
+ begin
513
+ type_custom_fields = custom_fields_for(type)
514
+ rescue => ex
515
+ return fields
516
+ end
517
+ transform = {}
518
+ fields.each do |name, value|
519
+ is_custom = type_custom_fields.select {|fn| fn.downcase == name.downcase}
520
+ if is_custom.length > 0
521
+ transform[is_custom.first.last] = value
522
+ else
523
+ transform[name] = value
524
+ end
525
+ end
526
+ transform
527
+ end
528
+
496
529
  def self.fix_case(values)
497
530
  values.inject({}) do |new_values, (key, value)|
498
531
  new_values[camel_case_word(key)] = value.is_a?(Hash) ? fix_case(value) : value
@@ -1,8 +1,8 @@
1
1
  # :nodoc:
2
- #Copyright (c) 2002-2012 Rally Software Development Corp. All Rights Reserved.
2
+ #Copyright (c) 2002-2015 Rally Software Development Corp. All Rights Reserved.
3
3
  #Your use of this Software is governed by the terms and conditions
4
4
  #of the applicable Subscription Agreement between your company and
5
5
  #Rally Software Development Corp.
6
6
  module RallyAPI
7
- VERSION = "1.1.2"
7
+ VERSION = "1.2.0"
8
8
  end
metadata CHANGED
@@ -1,30 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rally_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Smith
8
- - Rylee Keys-DuMars
8
+ - Rylee Keys
9
+ - Kip Lehman
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-10-16 00:00:00.000000000 Z
13
+ date: 2015-04-28 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: httpclient
16
17
  requirement: !ruby/object:Gem::Requirement
17
18
  requirements:
18
- - - ~>
19
+ - - '='
19
20
  - !ruby/object:Gem::Version
20
- version: 2.4.0
21
+ version: 2.5.0
21
22
  type: :runtime
22
23
  prerelease: false
23
24
  version_requirements: !ruby/object:Gem::Requirement
24
25
  requirements:
25
- - - ~>
26
+ - - '='
26
27
  - !ruby/object:Gem::Version
27
- version: 2.4.0
28
+ version: 2.5.0
28
29
  - !ruby/object:Gem::Dependency
29
30
  name: simplecov
30
31
  requirement: !ruby/object:Gem::Requirement
@@ -85,6 +86,7 @@ description: API wrapper for Rally's JSON REST web services api
85
86
  email:
86
87
  - dsmith@rallydev.com
87
88
  - rylee@rallydev.com
89
+ - klehman@rallydev.com
88
90
  executables: []
89
91
  extensions: []
90
92
  extra_rdoc_files: []
@@ -121,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  version: '0'
122
124
  requirements: []
123
125
  rubyforge_project: rally_api
124
- rubygems_version: 2.2.2
126
+ rubygems_version: 2.4.5
125
127
  signing_key:
126
128
  specification_version: 4
127
129
  summary: A wrapper for the Rally Web Services API using json