brpm_module_brpm 0.1.25 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/config.yml +1 -1
  3. data/lib/brpm_rest_client.rb +24 -33
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjY2YzYwMWRkMWUxOTNjYTBiZTVjYjY4YjEwNTAzZDE0NjJmNzdlNA==
4
+ MGVjM2UxNDU2ZGFmZWExODY2MDI4ZDAzMTVlYzgyMTVmOTZhOWI4MA==
5
5
  data.tar.gz: !binary |-
6
- NzMzNTMzZjQxY2U0MjNiMWYxODRiYmQ4ZTA1OTJkZWU0YjRmZTMxMg==
6
+ ZDg3YTQ0OWFjYjMzMzk2OGQxZTUyYmYzYWVlODM3MjkzYTYwMTc3OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmJlZjI0ZTA3YzZmNjczNWRjNjU4N2VlMzM0ODBmZjczM2YwMzc3ZDcxMDAx
10
- NjUwZGUxODJlMjAyYTc1Y2QyZWQ1ZWJlZmIwN2U4ZGIwMmE0YzhiYmQ0YTA0
11
- YzhmZDU3YmE5Yzk4ZTk2MjlkZDIwZjZjMDNmZmRlNWZlMjdjN2U=
9
+ NmE1NTE2NzA0MzUwOTQ1YmJhNjg3NzRjNzVhYTEwNDQ0NjQwNDRiMmE2YmQ5
10
+ YTczZTE4YjJkMGI3MGU2NmM1OGE3Y2RmNzViYjcxZmIyZjVmNDdhMDk4ZGM4
11
+ OTFlNWYzMWE4MjE0YmQ2YjNjYjMwZjEwMDc2NTM1MmFiM2MwMDE=
12
12
  data.tar.gz: !binary |-
13
- ZTQ5MGI3ZDc3YmJmZWQ1Y2EzOWQ4NzRhOTRmMTVkNTVjNzQ4NDliZjU5NTBh
14
- ZmIxZmFlODgwZmM4OTUwODRkNGJjMTZmNGI4NjE5ZDZmMTU3OTJhYTgyYTEx
15
- YzgxNDkyZjg5MzljNTJkNzUwMzc2ZTM1ODdjNjdkZGYzM2VlOTQ=
13
+ ZjQ0NzNlMmY2MjJiMGE5NTYyNzA4ZDkzMGU0MTBiNGRkN2QyMzU4YzdhNTUz
14
+ MTc2YjE5YWY0ZTFlYTMzM2Y5YmQ5NjFhMzQwMzdmZDZhNmUyMzIwOTk5YWUy
15
+ M2I2YTk1Mjc0NDlhZTA4YzY1ZmVlZDg1N2MwNzI4N2RjODQyOWU=
data/config.yml CHANGED
@@ -1,4 +1,4 @@
1
- version: 0.1.25
1
+ version: 0.1.26
2
2
 
3
3
  author: Niek Bartholomeus
4
4
  email: niek.bartholomeus@gmail.com
@@ -1633,10 +1633,14 @@ class BrpmRestClient
1633
1633
  end
1634
1634
 
1635
1635
  def get_script_by_name(name)
1636
- result = brpm_get "v1/scripts?filters[name]=#{name}"
1636
+ # TODO: the scripts REST API is not finished yet: get_script_by_name always returns "null". So for now we are going to create the script and if it returns an error that the name is already taken we will update it
1637
+
1638
+ # result = brpm_get "v1/scripts?filters[name]=#{name}"
1639
+ result = brpm_get "v1/scripts"
1637
1640
 
1638
1641
  if result["status"] == "success"
1639
- result_hash = result["response"].first
1642
+ # result_hash = result["response"].first
1643
+ result_hash = result["response"].find { |script| script["name"] == name}
1640
1644
  else
1641
1645
  if result["code"] == 404
1642
1646
  result_hash = nil
@@ -1691,44 +1695,31 @@ class BrpmRestClient
1691
1695
  end
1692
1696
 
1693
1697
  def create_or_update_script(script)
1694
- # TODO: the scripts REST API is not finished yet: get_script_by_name always returns "null". So for now we are going to create the script and if it returns an error that the name is already taken we will update it
1695
1698
 
1696
- # BrpmAuto.log "Checking if the corresponding script already exists ..."
1697
- # existing_script = get_script_by_name(script["name"])
1698
- #
1699
- # if existing_script.nil?
1700
- # BrpmAuto.log "Script doesn't exist yet."
1701
- # script_already_exists=false
1702
- # else
1703
- # BrpmAuto.log "Script already exists."
1704
- # script_already_exists=true
1705
- #
1706
- # script["id"] = existing_script["id"].to_s
1707
- # end
1699
+ BrpmAuto.log "Checking if the corresponding script already exists ..."
1700
+ existing_script = get_script_by_name(script["name"])
1701
+
1702
+ if existing_script.nil?
1703
+ BrpmAuto.log "Script doesn't exist yet."
1704
+ script_already_exists=false
1705
+ else
1706
+ BrpmAuto.log "Script already exists."
1707
+ script_already_exists=true
1708
+
1709
+ script["id"] = existing_script["id"].to_s
1710
+ end
1708
1711
 
1709
1712
  data = {}
1710
1713
  data["script"] = script
1711
1714
 
1712
- # if script_already_exists
1713
- # BrpmAuto.log "Updating the script..."
1714
- # script = update_script_from_hash(script)
1715
- # BrpmAuto.log "Script is updated."
1716
- # else
1717
- # BrpmAuto.log "Creating the script..."
1718
- # script = create_script_from_hash(script)
1719
- # BrpmAuto.log "Script is created."
1720
- # end
1721
-
1722
- BrpmAuto.log "Creating the script..."
1723
- begin
1715
+ if script_already_exists
1716
+ BrpmAuto.log "Updating the script..."
1717
+ script = update_script_from_hash(script)
1718
+ BrpmAuto.log "Script is updated."
1719
+ else
1720
+ BrpmAuto.log "Creating the script..."
1724
1721
  script = create_script_from_hash(script)
1725
1722
  BrpmAuto.log "Script is created."
1726
- rescue Exception => e
1727
- if "#{e}".include?("has already been taken")
1728
- BrpmAuto.log "Script already exists, updating it..."
1729
- script = update_script_from_hash(script)
1730
- BrpmAuto.log "Script is updated."
1731
- end
1732
1723
  end
1733
1724
 
1734
1725
  script
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brpm_module_brpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niek Bartholomeus