brpm_module_brpm 0.1.16 → 0.1.17
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 +8 -8
- data/config.yml +1 -1
- data/lib/brpm_rest_client.rb +116 -16
- data/tests/rest/list_items_spec.rb +29 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmJjNjFhOTNmMWI5N2Q3N2RkMmUyMDliOTg1ZTRmMmRkMzE2ZGZhZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTU5ZmE0ZDY0M2M2YWJjYjg4Mjk0OTAxZWYyMzc1MzQyNmJlMzA4Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzI2MmYzZjJmNzhlMTM5NDRhNGFkZmE0MDNlMDBiZmU2MGI4ODIwMGI4Mjc5
|
10
|
+
ZWE3MWI4MmM5MDYzZmM1NzEyMGEwN2Y3NTBhZDQ2ZTJjYmNjNWVjZWFmNTBl
|
11
|
+
YzY4MjQxNGVjMGU5YmE2NGU1NWM3ZThjYzI0MThkMjVlZjJiZjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTA5YTAyNjcxNWYyYTJjMmJkYzI0Njk4ZTZhYmFkYjcxZjY3Y2FjODAxYTNh
|
14
|
+
MGU5Y2QwOGFlNGFkNGE4NmQ4ZTUxODU0NTdhZGI3MDJjNzZiN2VjNTQ2MDc5
|
15
|
+
YzYyNTI0Yzg5MDBjNGEzYjU4MjAyZWM0ODgxZmY3NjFjY2NiNWU=
|
data/config.yml
CHANGED
data/lib/brpm_rest_client.rb
CHANGED
@@ -1434,6 +1434,106 @@ class BrpmRestClient
|
|
1434
1434
|
end
|
1435
1435
|
end
|
1436
1436
|
|
1437
|
+
def get_list_item_by_id(list_item_id)
|
1438
|
+
result = brpm_get "v1/list_items/#{list_item_id}"
|
1439
|
+
|
1440
|
+
if result["status"] == "success"
|
1441
|
+
result_hash = result["response"]
|
1442
|
+
else
|
1443
|
+
raise "Error searching for list item #{list_item_id}: #{result["error_message"]}"
|
1444
|
+
end
|
1445
|
+
|
1446
|
+
result_hash
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
def get_list_item_by_name(name)
|
1450
|
+
result = brpm_get "v1/list_items?filters[value_text]=#{name}"
|
1451
|
+
|
1452
|
+
if result["status"] == "success"
|
1453
|
+
result_hash = get_list_item_by_id(result["response"].first["id"])
|
1454
|
+
else
|
1455
|
+
if result["code"] == 404
|
1456
|
+
result_hash = nil
|
1457
|
+
else
|
1458
|
+
raise "Could not find list item #{name}: #{result["error_message"]}"
|
1459
|
+
end
|
1460
|
+
end
|
1461
|
+
|
1462
|
+
result_hash
|
1463
|
+
end
|
1464
|
+
|
1465
|
+
def get_list_items_by(filter)
|
1466
|
+
filter_string = "?"
|
1467
|
+
filter.each do |key, value|
|
1468
|
+
filter_string += "filters[#{key}]=#{value}&"
|
1469
|
+
end
|
1470
|
+
filter_string = filter_string[0..-1]
|
1471
|
+
|
1472
|
+
result = brpm_get "v1/list_items#{filter_string}"
|
1473
|
+
|
1474
|
+
if result["status"] == "success"
|
1475
|
+
result_hash = result["response"]
|
1476
|
+
else
|
1477
|
+
if result["code"] == 404
|
1478
|
+
result_hash = {}
|
1479
|
+
else
|
1480
|
+
raise "Error searching for list items by #{filter_string}: #{result["error_message"]}"
|
1481
|
+
end
|
1482
|
+
end
|
1483
|
+
|
1484
|
+
result_hash
|
1485
|
+
end
|
1486
|
+
|
1487
|
+
def create_list_item_from_hash(list_item)
|
1488
|
+
result = brpm_post "v1/list_items", { :list_item => list_item }
|
1489
|
+
|
1490
|
+
unless result["status"] == "success"
|
1491
|
+
raise "Could not create the list item: #{result["error_message"]}"
|
1492
|
+
end
|
1493
|
+
|
1494
|
+
result["response"]
|
1495
|
+
end
|
1496
|
+
|
1497
|
+
def update_list_item_from_hash(list_item)
|
1498
|
+
result = brpm_put "v1/list_items/#{list_item["id"]}", { :list_item => list_item }
|
1499
|
+
|
1500
|
+
unless result["status"] == "success"
|
1501
|
+
raise "Could not update the list item: #{result["error_message"]}"
|
1502
|
+
end
|
1503
|
+
|
1504
|
+
result["response"]
|
1505
|
+
end
|
1506
|
+
|
1507
|
+
def create_or_update_list_item(list_item)
|
1508
|
+
BrpmAuto.log "Checking if the corresponding list item already exists ..."
|
1509
|
+
existing_list_item = get_list_item_by_name list_item["name"]
|
1510
|
+
|
1511
|
+
if existing_list_item.nil?
|
1512
|
+
BrpmAuto.log "List item doesn't exist yet."
|
1513
|
+
list_item_already_exists=false
|
1514
|
+
else
|
1515
|
+
BrpmAuto.log "List item already exists."
|
1516
|
+
list_item_already_exists=true
|
1517
|
+
|
1518
|
+
list_item["id"] = existing_list_item["id"].to_s
|
1519
|
+
end
|
1520
|
+
|
1521
|
+
data = {}
|
1522
|
+
data["list_item"] = list_item
|
1523
|
+
|
1524
|
+
if list_item_already_exists
|
1525
|
+
BrpmAuto.log "Updating the list item..."
|
1526
|
+
list_item = update_list_item_from_hash(list_item)
|
1527
|
+
BrpmAuto.log "list_item is updated."
|
1528
|
+
else
|
1529
|
+
BrpmAuto.log "Creating the list item..."
|
1530
|
+
list_item = create_list_item_from_hash(list_item)
|
1531
|
+
BrpmAuto.log "List item is created."
|
1532
|
+
end
|
1533
|
+
|
1534
|
+
list_item
|
1535
|
+
end
|
1536
|
+
|
1437
1537
|
def get_script_by_name(name)
|
1438
1538
|
result = brpm_get "v1/scripts?filters[name]=#{name}"
|
1439
1539
|
|
@@ -1522,6 +1622,22 @@ class BrpmRestClient
|
|
1522
1622
|
script
|
1523
1623
|
end
|
1524
1624
|
|
1625
|
+
def get_work_task_by_name(name)
|
1626
|
+
result = brpm_get "v1/work_tasks?filters[name]=#{name}"
|
1627
|
+
|
1628
|
+
if result["status"] == "success"
|
1629
|
+
result_hash = result["response"].first
|
1630
|
+
else
|
1631
|
+
if result["code"] == 404
|
1632
|
+
result_hash = nil
|
1633
|
+
else
|
1634
|
+
raise "Could not find work_task #{name}: #{result["error_message"]}"
|
1635
|
+
end
|
1636
|
+
end
|
1637
|
+
|
1638
|
+
result_hash
|
1639
|
+
end
|
1640
|
+
|
1525
1641
|
def sync_attributes(existing_attributes, updated_attributes)
|
1526
1642
|
existing_attributes ||= []
|
1527
1643
|
updated_attributes ||= []
|
@@ -1555,22 +1671,6 @@ class BrpmRestClient
|
|
1555
1671
|
attribute["value_text"] = value
|
1556
1672
|
end
|
1557
1673
|
|
1558
|
-
def get_work_task_by_name(name)
|
1559
|
-
result = brpm_get "v1/work_tasks?filters[name]=#{name}"
|
1560
|
-
|
1561
|
-
if result["status"] == "success"
|
1562
|
-
result_hash = result["response"].first
|
1563
|
-
else
|
1564
|
-
if result["code"] == 404
|
1565
|
-
result_hash = nil
|
1566
|
-
else
|
1567
|
-
raise "Could not find work_task #{name}: #{result["error_message"]}"
|
1568
|
-
end
|
1569
|
-
end
|
1570
|
-
|
1571
|
-
result_hash
|
1572
|
-
end
|
1573
|
-
|
1574
1674
|
# Sends an email based on step recipients
|
1575
1675
|
#
|
1576
1676
|
# ==== Attributes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
describe 'List items REST API' do
|
4
|
+
before(:all) do
|
5
|
+
setup_brpm_auto
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should create, read, update and delete a list item' do
|
9
|
+
list_item = {}
|
10
|
+
list_item["list_id"] = 24 # AutomationCategory
|
11
|
+
list_item["value_text"] = "MyAutomationCategory"
|
12
|
+
list_item = @brpm_rest_client.create_list_item_from_hash(list_item)
|
13
|
+
|
14
|
+
expect(list_item["list"]["id"]).to eq(24)
|
15
|
+
expect(list_item["value_text"]).to eq("MyAutomationCategory")
|
16
|
+
|
17
|
+
list_item = @brpm_rest_client.get_list_item_by_name("MyAutomationCategory")
|
18
|
+
|
19
|
+
expect(list_item["list"]["id"]).to eq(24)
|
20
|
+
expect(list_item["value_text"]).to eq("MyAutomationCategory")
|
21
|
+
|
22
|
+
list_item["value_text"] += " - UPDATED"
|
23
|
+
list_item = @brpm_rest_client.update_list_item_from_hash(list_item)
|
24
|
+
|
25
|
+
expect(list_item["list"]["id"]).to eq(24)
|
26
|
+
expect(list_item["value_text"]).to eq("MyAutomationCategory - UPDATED")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brpm_module_brpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Niek Bartholomeus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brpm_content
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- resource_automations/select_step_in_request.txt
|
98
98
|
- tests/create_release_request_spec.rb
|
99
99
|
- tests/create_request_spec.rb
|
100
|
+
- tests/rest/list_items_spec.rb
|
100
101
|
- tests/select_application_version_spec.rb
|
101
102
|
- tests/spec_helper.rb
|
102
103
|
homepage: https://github.com/BMC-RLM/brpm_module_brpm
|