killbill-client 0.25.0 → 0.26.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: fb18f53ec0f189873ead4aa108eb179a408e9ff0
4
- data.tar.gz: dda47189a049314516f2e99ac59e9f4d78f7022e
3
+ metadata.gz: 4c05cca45d6b7e61f60a468ebbc61658fe6bcf8f
4
+ data.tar.gz: 09a5cb5b091bbd1db3e64a6ef26eff5651ed2b19
5
5
  SHA512:
6
- metadata.gz: fcd13fd28cf9013264a615b6794b2cf8a8cf957ca686131ecc599402e779445dea9fdc7e0bf9af7d1367d62931f5825cf80c1da19d5925bfd989d3055d9aea39
7
- data.tar.gz: 4193a5fe86f3a97160403070896bbc46e98ad0877ae72f24b7b99bdc9fcb6ae28a776f1510fc45f94cb0247ec71ed1098c8cc78119d676c2cf76273015e68cf7
6
+ metadata.gz: d3684e3a7b23f59c0df340c6b86eb2cf9b75f8e290d4d0609784a80b69480f78c50677619fa15b4ae539c85f11754925ef07f67cec59ad1b4d6abf603623f94b
7
+ data.tar.gz: 4df324054c188d5544d8bfd140f2c1dc2c61c6cbbae5058aea500aead6ff587be23c86e7b922d440203334ff7fee3c582bee67de052c622053f1d9241f336390
@@ -1,6 +1,6 @@
1
1
  module KillBillClient
2
2
  module Model
3
- class Catalog < CatalogAttributesSimple
3
+ class Catalog < CatalogAttributes
4
4
 
5
5
  has_many :products, KillBillClient::Model::Product
6
6
 
@@ -1,3 +1,5 @@
1
+ require 'timeout'
2
+
1
3
  module KillBillClient
2
4
  module Model
3
5
  class NodesInfo < NodeInfoAttributes
@@ -14,6 +16,38 @@ module KillBillClient
14
16
  options
15
17
  end
16
18
 
19
+
20
+ def start_plugin_wait_for_plugin_command_completion(plugin_name, plugin_version=nil, local_node_only=false, user = nil, reason = nil, comment = nil, options = {}, timeout_sec=10, sleep_sec=1)
21
+
22
+ proc_condition = create_proc_condition_for_wait_for_plugin_command_completion(options, plugin_name, plugin_version, "RUNNING")
23
+
24
+ trigger_node_command_wait_for_plugin_command_completion(:START_PLUGIN, nil, plugin_name, plugin_version, local_node_only, user, reason, comment, options, timeout_sec, sleep_sec, &proc_condition)
25
+ end
26
+
27
+ def stop_plugin_wait_for_plugin_command_completion(plugin_name, plugin_version=nil, local_node_only=false, user = nil, reason = nil, comment = nil, options = {}, timeout_sec=10, sleep_sec=1)
28
+
29
+ proc_condition = create_proc_condition_for_wait_for_plugin_command_completion(options, plugin_name, plugin_version, "STOPPED")
30
+
31
+ trigger_node_command_wait_for_plugin_command_completion(:STOP_PLUGIN, nil, plugin_name, plugin_version, local_node_only, user, reason, comment, options, timeout_sec, sleep_sec, &proc_condition)
32
+ end
33
+
34
+
35
+ def install_plugin_wait_for_plugin_command_completion(plugin_key, plugin_name, plugin_version=nil, local_node_only=false, user = nil, reason = nil, comment = nil, options = {}, timeout_sec=20, sleep_sec=1)
36
+
37
+ proc_condition = create_proc_condition_for_wait_for_plugin_command_completion(options, plugin_name, plugin_version, nil)
38
+
39
+ trigger_node_command_wait_for_plugin_command_completion(:INSTALL_PLUGIN, plugin_key, plugin_name, plugin_version, local_node_only, user, reason, comment, options, timeout_sec, sleep_sec, &proc_condition)
40
+ end
41
+
42
+ def uninstall_plugin_wait_for_plugin_command_completion(plugin_name, plugin_version=nil, local_node_only=false, user = nil, reason = nil, comment = nil, options = {}, timeout_sec=10, sleep_sec=1)
43
+
44
+ is_negate = true # We are looking for absence of plugin_info from result (after plugin got successfully uninstalled)
45
+ proc_condition = create_proc_condition_for_wait_for_plugin_command_completion(options, plugin_name, plugin_version, nil, is_negate)
46
+
47
+ trigger_node_command_wait_for_plugin_command_completion(:UNINSTALL_PLUGIN, nil, plugin_name, plugin_version, local_node_only, user, reason, comment, options, timeout_sec, sleep_sec, &proc_condition)
48
+ end
49
+
50
+
17
51
  def trigger_node_command(node_command, local_node_only, user = nil, reason = nil, comment = nil, options = {})
18
52
  post KILLBILL_NODES_INFO_PREFIX,
19
53
  node_command.to_json,
@@ -25,6 +59,60 @@ module KillBillClient
25
59
  }.merge(options)
26
60
  end
27
61
 
62
+ private
63
+
64
+ def trigger_node_command_wait_for_plugin_command_completion(node_command_type, plugin_key, plugin_name, plugin_version, local_node_only, user, reason, comment, options, timeout_sec, sleep_sec, &proc_condition)
65
+ # Idempotency : Check if already installed
66
+ res = proc_condition.call
67
+ return res if res
68
+
69
+ node_command = KillBillClient::Model::NodeCommandAttributes.new
70
+ node_command.system_command_type = true
71
+ node_command.node_command_type = node_command_type
72
+ node_command.node_command_properties = []
73
+ node_command.node_command_properties << {:key => 'pluginName', :value => plugin_name} if plugin_name
74
+ node_command.node_command_properties << {:key => 'pluginKey', :value => plugin_key} if plugin_key
75
+ node_command.node_command_properties << {:key => 'pluginVersion', :value => plugin_version} if plugin_version
76
+
77
+ KillBillClient::Model::NodesInfo.trigger_node_command(node_command, local_node_only, user, reason, comment, options)
78
+
79
+ wait_for_plugin_command_completion(node_command_type, plugin_key || plugin_name,timeout_sec, sleep_sec, &proc_condition)
80
+ end
81
+
82
+ def create_proc_condition_for_wait_for_plugin_command_completion(options, plugin_name, plugin_version, state=nil, is_negate=false)
83
+ proc_condition = Proc.new {
84
+ node_infos = KillBillClient::Model::NodesInfo.nodes_info(options)
85
+
86
+ res = true
87
+ node_infos.each do |info|
88
+ raw_node_res = info.plugins_info.find do |e|
89
+ e.plugin_name == plugin_name && ((plugin_version.nil? && e.is_selected_for_start) || plugin_version == e.plugin_version) && (state.nil? || e.state == state)
90
+ end
91
+ node_res = is_negate ? !raw_node_res : raw_node_res
92
+ res = res & node_res
93
+ end
94
+ res
95
+ }
96
+ proc_condition
97
+ end
98
+
99
+ def wait_for_plugin_command_completion(command, plugin, timeout_sec, sleep_sec)
100
+ begin
101
+ Timeout::timeout(timeout_sec) do
102
+ while true do
103
+ installed_plugin = yield
104
+ return installed_plugin if installed_plugin
105
+ sleep(sleep_sec)
106
+ end
107
+ end
108
+ rescue Timeout::Error => e
109
+ if KillBillClient.logger
110
+ KillBillClient.log :info, 'Reached timeout after %s sec: command=%s, plugin=%s' % [timeout_sec, command, plugin]
111
+ end
112
+ raise e
113
+ end
114
+ end
115
+
28
116
  end
29
117
 
30
118
  end
@@ -1,7 +1,7 @@
1
1
  module KillBillClient
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 25
4
+ MINOR = 26
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
metadata CHANGED
@@ -1,65 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Killbill core team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2015-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.2.0
20
- requirement: !ruby/object:Gem::Requirement
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
21
23
  requirements:
22
- - - '>='
24
+ - - ">="
23
25
  - !ruby/object:Gem::Version
24
26
  version: 1.2.0
25
- prerelease: false
26
- type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 10.0.0
34
- requirement: !ruby/object:Gem::Requirement
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
35
37
  requirements:
36
- - - '>='
38
+ - - ">="
37
39
  - !ruby/object:Gem::Version
38
40
  version: 10.0.0
39
- prerelease: false
40
- type: :development
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
- version_requirements: !ruby/object:Gem::Requirement
43
+ requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.12.0
48
- requirement: !ruby/object:Gem::Requirement
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
49
51
  requirements:
50
- - - ~>
52
+ - - "~>"
51
53
  - !ruby/object:Gem::Version
52
54
  version: 2.12.0
53
- prerelease: false
54
- type: :development
55
55
  description: An API client library for Kill Bill.
56
56
  email: killbilling-users@googlegroups.com
57
57
  executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - .gitignore
62
- - .travis.yml
61
+ - ".gitignore"
62
+ - ".travis.yml"
63
63
  - Gemfile
64
64
  - README.md
65
65
  - Rakefile
@@ -89,7 +89,6 @@ files:
89
89
  - lib/killbill_client/models/gen/bundle_attributes.rb
90
90
  - lib/killbill_client/models/gen/bundle_timeline_attributes.rb
91
91
  - lib/killbill_client/models/gen/catalog_attributes.rb
92
- - lib/killbill_client/models/gen/catalog_attributes_simple.rb
93
92
  - lib/killbill_client/models/gen/combo_hosted_payment_page_attributes.rb
94
93
  - lib/killbill_client/models/gen/combo_payment_transaction_attributes.rb
95
94
  - lib/killbill_client/models/gen/credit_attributes.rb
@@ -186,26 +185,26 @@ homepage: http://www.killbilling.org
186
185
  licenses:
187
186
  - Apache License (2.0)
188
187
  metadata: {}
189
- post_install_message:
188
+ post_install_message:
190
189
  rdoc_options:
191
- - --exclude
192
- - .
190
+ - "--exclude"
191
+ - "."
193
192
  require_paths:
194
193
  - lib
195
194
  required_ruby_version: !ruby/object:Gem::Requirement
196
195
  requirements:
197
- - - '>='
196
+ - - ">="
198
197
  - !ruby/object:Gem::Version
199
198
  version: 1.8.6
200
199
  required_rubygems_version: !ruby/object:Gem::Requirement
201
200
  requirements:
202
- - - '>='
201
+ - - ">="
203
202
  - !ruby/object:Gem::Version
204
203
  version: '0'
205
204
  requirements: []
206
- rubyforge_project:
207
- rubygems_version: 2.4.6
208
- signing_key:
205
+ rubyforge_project:
206
+ rubygems_version: 2.2.2
207
+ signing_key:
209
208
  specification_version: 4
210
209
  summary: Kill Bill client library.
211
210
  test_files:
@@ -1,35 +0,0 @@
1
- #############################################################################################
2
- # #
3
- # Copyright 2010-2013 Ning, Inc. #
4
- # Copyright 2014 Groupon, Inc. #
5
- # Copyright 2014 The Billing Project, LLC #
6
- # #
7
- # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
- # (the "License"); you may not use this file except in compliance with the #
9
- # License. You may obtain a copy of the License at: #
10
- # #
11
- # http://www.apache.org/licenses/LICENSE-2.0 #
12
- # #
13
- # Unless required by applicable law or agreed to in writing, software #
14
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
- # License for the specific language governing permissions and limitations #
17
- # under the License. #
18
- # #
19
- #############################################################################################
20
-
21
-
22
- #
23
- # DO NOT EDIT!!!
24
- # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
- #
26
-
27
-
28
- module KillBillClient
29
- module Model
30
- class CatalogAttributesSimple < Resource
31
- attribute :name
32
- attribute :products
33
- end
34
- end
35
- end