3scale_toolbox 0.11.0 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/3scale_toolbox.gemspec +42 -0
- data/LICENSE +201 -0
- data/NOTICE +15 -0
- data/README.md +8 -0
- data/lib/3scale_toolbox.rb +1 -0
- data/lib/3scale_toolbox/commands/application_command/apply_command.rb +21 -6
- data/lib/3scale_toolbox/commands/application_command/create_command.rb +3 -1
- data/lib/3scale_toolbox/commands/copy_command/copy_service.rb +5 -0
- data/lib/3scale_toolbox/commands/import_command/openapi.rb +5 -3
- data/lib/3scale_toolbox/commands/import_command/openapi/create_activedocs_step.rb +10 -2
- data/lib/3scale_toolbox/commands/import_command/openapi/create_method_step.rb +13 -6
- data/lib/3scale_toolbox/commands/import_command/openapi/method.rb +5 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/step.rb +4 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/threescale_api_spec.rb +2 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/update_service_proxy_step.rb +12 -5
- data/lib/3scale_toolbox/commands/metrics_command/list_command.rb +1 -8
- data/lib/3scale_toolbox/commands/plans_command/apply_command.rb +8 -7
- data/lib/3scale_toolbox/commands/plans_command/create_command.rb +0 -2
- data/lib/3scale_toolbox/commands/plans_command/export/read_plan_methods_step.rb +0 -3
- data/lib/3scale_toolbox/commands/plans_command/export/read_plan_metrics_step.rb +0 -2
- data/lib/3scale_toolbox/commands/plans_command/export/read_plan_pricing_rules_step.rb +2 -1
- data/lib/3scale_toolbox/commands/plans_command/export/step.rb +0 -2
- data/lib/3scale_toolbox/commands/plans_command/import/create_or_update_app_plan_step.rb +8 -3
- data/lib/3scale_toolbox/commands/plans_command/import/import_plan_metrics_step.rb +0 -3
- data/lib/3scale_toolbox/commands/plans_command/import/import_plan_pricing_rules_step.rb +9 -2
- data/lib/3scale_toolbox/commands/plans_command/import/step.rb +5 -1
- data/lib/3scale_toolbox/commands/proxy_config_command/promote_command.rb +21 -5
- data/lib/3scale_toolbox/entities/account.rb +44 -4
- data/lib/3scale_toolbox/entities/activedocs.rb +1 -1
- data/lib/3scale_toolbox/entities/application.rb +21 -13
- data/lib/3scale_toolbox/entities/application_plan.rb +13 -12
- data/lib/3scale_toolbox/entities/base_entity.rb +1 -1
- data/lib/3scale_toolbox/entities/method.rb +1 -1
- data/lib/3scale_toolbox/entities/metric.rb +1 -1
- data/lib/3scale_toolbox/entities/service.rb +30 -15
- data/lib/3scale_toolbox/remotes.rb +1 -1
- data/lib/3scale_toolbox/resource_reader.rb +5 -2
- data/lib/3scale_toolbox/swagger/swagger.rb +5 -3
- data/lib/3scale_toolbox/tasks/copy_activedocs_task.rb +27 -9
- data/lib/3scale_toolbox/tasks/copy_limits_task.rb +4 -1
- data/lib/3scale_toolbox/tasks/copy_mapping_rules_task.rb +4 -1
- data/lib/3scale_toolbox/tasks/copy_methods_task.rb +20 -16
- data/lib/3scale_toolbox/tasks/copy_metrics_task.rb +14 -14
- data/lib/3scale_toolbox/tasks/copy_pricingrules_task.rb +4 -1
- data/lib/3scale_toolbox/tasks/copy_task.rb +40 -0
- data/lib/3scale_toolbox/version.rb +1 -1
- data/licenses.xml +303 -0
- metadata +8 -4
@@ -4,27 +4,27 @@ module ThreeScaleToolbox
|
|
4
4
|
include CopyTask
|
5
5
|
|
6
6
|
def call
|
7
|
-
source_metrics = source.metrics
|
8
|
-
target_metrics = target.metrics
|
9
|
-
|
10
7
|
puts "original service has #{source_metrics.size} metrics"
|
11
8
|
puts "target service has #{target_metrics.size} metrics"
|
9
|
+
missing_metrics.each(&method(:create_metric))
|
10
|
+
puts "created #{missing_metrics.size} metrics on the target service"
|
11
|
+
invalidate_target_metrics if missing_metrics.size.positive?
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
+
private
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def create_metric(metric)
|
17
|
+
new_metric = metric.reject { |key, _| %w[id links].include? key }
|
18
|
+
Entities::Metric.create(service: target, attrs: new_metric)
|
19
|
+
rescue ThreeScaleToolbox::ThreeScaleApiError => e
|
20
|
+
raise e unless ThreeScaleToolbox::Helper.system_name_already_taken_error?(e.apierrors)
|
19
21
|
|
20
|
-
|
22
|
+
warn "[WARN] metric #{metric.fetch('system_name')} not created. " \
|
23
|
+
'Method with the same system_name exists.'
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
def missing_metrics(source_metrics, target_metrics)
|
26
|
-
ThreeScaleToolbox::Helper.array_difference(source_metrics,
|
27
|
-
target_metrics) do |source, target|
|
26
|
+
def missing_metrics
|
27
|
+
@missing_metrics ||= ThreeScaleToolbox::Helper.array_difference(source_metrics, target_metrics) do |source, target|
|
28
28
|
ThreeScaleToolbox::Helper.compare_hashes(source, target, ['system_name'])
|
29
29
|
end
|
30
30
|
end
|
@@ -5,7 +5,6 @@ module ThreeScaleToolbox
|
|
5
5
|
include Helper
|
6
6
|
|
7
7
|
def call
|
8
|
-
metrics_map = metrics_mapping(source.metrics, target.metrics)
|
9
8
|
plan_mapping = application_plan_mapping(source.plans, target.plans)
|
10
9
|
plan_mapping.each do |plan_id, target_plan|
|
11
10
|
pricing_rules_source = source.remote.list_pricingrules_per_application_plan(plan_id)
|
@@ -27,6 +26,10 @@ module ThreeScaleToolbox
|
|
27
26
|
|
28
27
|
private
|
29
28
|
|
29
|
+
def metrics_map
|
30
|
+
@metrics_map ||= metrics_mapping(source_metrics_and_methods, target_metrics_and_methods)
|
31
|
+
end
|
32
|
+
|
30
33
|
def missing_pricing_rules(source_pricing_rules, target_pricing_rules, metrics_map)
|
31
34
|
ThreeScaleToolbox::Helper.array_difference(source_pricing_rules, target_pricing_rules) do |src, target|
|
32
35
|
ThreeScaleToolbox::Helper.compare_hashes(src, target, %w[cost_per_unit min max]) &&
|
@@ -21,6 +21,46 @@ module ThreeScaleToolbox
|
|
21
21
|
def target
|
22
22
|
context[:target]
|
23
23
|
end
|
24
|
+
|
25
|
+
def source_metrics
|
26
|
+
context[:source_metrics] ||= source.metrics
|
27
|
+
end
|
28
|
+
|
29
|
+
def source_hits
|
30
|
+
context[:source_hits] ||= source.hits
|
31
|
+
end
|
32
|
+
|
33
|
+
def source_methods
|
34
|
+
context[:source_methods] ||= source.methods(source_hits.fetch('id'))
|
35
|
+
end
|
36
|
+
|
37
|
+
def source_metrics_and_methods
|
38
|
+
source_metrics + source_methods
|
39
|
+
end
|
40
|
+
|
41
|
+
def target_metrics
|
42
|
+
context[:target_metrics] ||= target.metrics
|
43
|
+
end
|
44
|
+
|
45
|
+
def target_hits
|
46
|
+
context[:target_hits] ||= target.hits
|
47
|
+
end
|
48
|
+
|
49
|
+
def target_methods
|
50
|
+
context[:target_methods] ||= target.methods(target_hits.fetch('id'))
|
51
|
+
end
|
52
|
+
|
53
|
+
def target_metrics_and_methods
|
54
|
+
target_metrics + target_methods
|
55
|
+
end
|
56
|
+
|
57
|
+
def invalidate_target_methods
|
58
|
+
context[:target_methods] = nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def invalidate_target_metrics
|
62
|
+
context[:target_metrics] = nil
|
63
|
+
end
|
24
64
|
end
|
25
65
|
end
|
26
66
|
end
|
data/licenses.xml
ADDED
@@ -0,0 +1,303 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<licenseSummary>
|
3
|
+
<dependencies>
|
4
|
+
<dependency>
|
5
|
+
<packageName>3scale-api</packageName>
|
6
|
+
<version>0.6.0</version>
|
7
|
+
<licenses>
|
8
|
+
<license>
|
9
|
+
<name>MIT</name>
|
10
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
11
|
+
</license>
|
12
|
+
</licenses>
|
13
|
+
</dependency>
|
14
|
+
<dependency>
|
15
|
+
<packageName>3scale_toolbox</packageName>
|
16
|
+
<version>0.12.0</version>
|
17
|
+
<licenses>
|
18
|
+
<license>
|
19
|
+
<name>MIT</name>
|
20
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
21
|
+
</license>
|
22
|
+
</licenses>
|
23
|
+
</dependency>
|
24
|
+
<dependency>
|
25
|
+
<packageName>addressable</packageName>
|
26
|
+
<version>2.6.0</version>
|
27
|
+
<licenses>
|
28
|
+
<license>
|
29
|
+
<name>Apache 2.0</name>
|
30
|
+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
31
|
+
</license>
|
32
|
+
</licenses>
|
33
|
+
</dependency>
|
34
|
+
<dependency>
|
35
|
+
<packageName>bundler</packageName>
|
36
|
+
<version>1.16.6</version>
|
37
|
+
<licenses>
|
38
|
+
<license>
|
39
|
+
<name>unknown</name>
|
40
|
+
<url></url>
|
41
|
+
</license>
|
42
|
+
</licenses>
|
43
|
+
</dependency>
|
44
|
+
<dependency>
|
45
|
+
<packageName>coderay</packageName>
|
46
|
+
<version>1.1.2</version>
|
47
|
+
<licenses>
|
48
|
+
<license>
|
49
|
+
<name>MIT</name>
|
50
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
51
|
+
</license>
|
52
|
+
</licenses>
|
53
|
+
</dependency>
|
54
|
+
<dependency>
|
55
|
+
<packageName>crack</packageName>
|
56
|
+
<version>0.4.3</version>
|
57
|
+
<licenses>
|
58
|
+
<license>
|
59
|
+
<name>MIT</name>
|
60
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
61
|
+
</license>
|
62
|
+
</licenses>
|
63
|
+
</dependency>
|
64
|
+
<dependency>
|
65
|
+
<packageName>cri</packageName>
|
66
|
+
<version>2.15.9</version>
|
67
|
+
<licenses>
|
68
|
+
<license>
|
69
|
+
<name>MIT</name>
|
70
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
71
|
+
</license>
|
72
|
+
</licenses>
|
73
|
+
</dependency>
|
74
|
+
<dependency>
|
75
|
+
<packageName>diff-lcs</packageName>
|
76
|
+
<version>1.3</version>
|
77
|
+
<licenses>
|
78
|
+
<license>
|
79
|
+
<name>MIT</name>
|
80
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
81
|
+
</license>
|
82
|
+
<license>
|
83
|
+
<name>Artistic-2.0</name>
|
84
|
+
<url></url>
|
85
|
+
</license>
|
86
|
+
<license>
|
87
|
+
<name>GPL-2.0+</name>
|
88
|
+
<url></url>
|
89
|
+
</license>
|
90
|
+
</licenses>
|
91
|
+
</dependency>
|
92
|
+
<dependency>
|
93
|
+
<packageName>dotenv</packageName>
|
94
|
+
<version>2.7.2</version>
|
95
|
+
<licenses>
|
96
|
+
<license>
|
97
|
+
<name>MIT</name>
|
98
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
99
|
+
</license>
|
100
|
+
</licenses>
|
101
|
+
</dependency>
|
102
|
+
<dependency>
|
103
|
+
<packageName>hashdiff</packageName>
|
104
|
+
<version>0.3.8</version>
|
105
|
+
<licenses>
|
106
|
+
<license>
|
107
|
+
<name>MIT</name>
|
108
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
109
|
+
</license>
|
110
|
+
</licenses>
|
111
|
+
</dependency>
|
112
|
+
<dependency>
|
113
|
+
<packageName>json-schema</packageName>
|
114
|
+
<version>2.8.1</version>
|
115
|
+
<licenses>
|
116
|
+
<license>
|
117
|
+
<name>MIT</name>
|
118
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
119
|
+
</license>
|
120
|
+
</licenses>
|
121
|
+
</dependency>
|
122
|
+
<dependency>
|
123
|
+
<packageName>license_finder</packageName>
|
124
|
+
<version>5.7.1</version>
|
125
|
+
<licenses>
|
126
|
+
<license>
|
127
|
+
<name>MIT</name>
|
128
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
129
|
+
</license>
|
130
|
+
</licenses>
|
131
|
+
</dependency>
|
132
|
+
<dependency>
|
133
|
+
<packageName>method_source</packageName>
|
134
|
+
<version>0.9.2</version>
|
135
|
+
<licenses>
|
136
|
+
<license>
|
137
|
+
<name>MIT</name>
|
138
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
139
|
+
</license>
|
140
|
+
</licenses>
|
141
|
+
</dependency>
|
142
|
+
<dependency>
|
143
|
+
<packageName>parslet</packageName>
|
144
|
+
<version>1.8.2</version>
|
145
|
+
<licenses>
|
146
|
+
<license>
|
147
|
+
<name>MIT</name>
|
148
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
149
|
+
</license>
|
150
|
+
</licenses>
|
151
|
+
</dependency>
|
152
|
+
<dependency>
|
153
|
+
<packageName>pry</packageName>
|
154
|
+
<version>0.12.2</version>
|
155
|
+
<licenses>
|
156
|
+
<license>
|
157
|
+
<name>MIT</name>
|
158
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
159
|
+
</license>
|
160
|
+
</licenses>
|
161
|
+
</dependency>
|
162
|
+
<dependency>
|
163
|
+
<packageName>public_suffix</packageName>
|
164
|
+
<version>3.0.3</version>
|
165
|
+
<licenses>
|
166
|
+
<license>
|
167
|
+
<name>MIT</name>
|
168
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
169
|
+
</license>
|
170
|
+
</licenses>
|
171
|
+
</dependency>
|
172
|
+
<dependency>
|
173
|
+
<packageName>rake</packageName>
|
174
|
+
<version>10.5.0</version>
|
175
|
+
<licenses>
|
176
|
+
<license>
|
177
|
+
<name>MIT</name>
|
178
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
179
|
+
</license>
|
180
|
+
</licenses>
|
181
|
+
</dependency>
|
182
|
+
<dependency>
|
183
|
+
<packageName>rspec</packageName>
|
184
|
+
<version>3.8.0</version>
|
185
|
+
<licenses>
|
186
|
+
<license>
|
187
|
+
<name>MIT</name>
|
188
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
189
|
+
</license>
|
190
|
+
</licenses>
|
191
|
+
</dependency>
|
192
|
+
<dependency>
|
193
|
+
<packageName>rspec-core</packageName>
|
194
|
+
<version>3.8.0</version>
|
195
|
+
<licenses>
|
196
|
+
<license>
|
197
|
+
<name>MIT</name>
|
198
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
199
|
+
</license>
|
200
|
+
</licenses>
|
201
|
+
</dependency>
|
202
|
+
<dependency>
|
203
|
+
<packageName>rspec-expectations</packageName>
|
204
|
+
<version>3.8.2</version>
|
205
|
+
<licenses>
|
206
|
+
<license>
|
207
|
+
<name>MIT</name>
|
208
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
209
|
+
</license>
|
210
|
+
</licenses>
|
211
|
+
</dependency>
|
212
|
+
<dependency>
|
213
|
+
<packageName>rspec-mocks</packageName>
|
214
|
+
<version>3.8.0</version>
|
215
|
+
<licenses>
|
216
|
+
<license>
|
217
|
+
<name>MIT</name>
|
218
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
219
|
+
</license>
|
220
|
+
</licenses>
|
221
|
+
</dependency>
|
222
|
+
<dependency>
|
223
|
+
<packageName>rspec-support</packageName>
|
224
|
+
<version>3.8.0</version>
|
225
|
+
<licenses>
|
226
|
+
<license>
|
227
|
+
<name>MIT</name>
|
228
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
229
|
+
</license>
|
230
|
+
</licenses>
|
231
|
+
</dependency>
|
232
|
+
<dependency>
|
233
|
+
<packageName>rubyzip</packageName>
|
234
|
+
<version>1.2.2</version>
|
235
|
+
<licenses>
|
236
|
+
<license>
|
237
|
+
<name>Simplified BSD</name>
|
238
|
+
<url>http://opensource.org/licenses/bsd-license</url>
|
239
|
+
</license>
|
240
|
+
</licenses>
|
241
|
+
</dependency>
|
242
|
+
<dependency>
|
243
|
+
<packageName>safe_yaml</packageName>
|
244
|
+
<version>1.0.5</version>
|
245
|
+
<licenses>
|
246
|
+
<license>
|
247
|
+
<name>MIT</name>
|
248
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
249
|
+
</license>
|
250
|
+
</licenses>
|
251
|
+
</dependency>
|
252
|
+
<dependency>
|
253
|
+
<packageName>thor</packageName>
|
254
|
+
<version>0.20.3</version>
|
255
|
+
<licenses>
|
256
|
+
<license>
|
257
|
+
<name>MIT</name>
|
258
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
259
|
+
</license>
|
260
|
+
</licenses>
|
261
|
+
</dependency>
|
262
|
+
<dependency>
|
263
|
+
<packageName>toml</packageName>
|
264
|
+
<version>0.2.0</version>
|
265
|
+
<licenses>
|
266
|
+
<license>
|
267
|
+
<name>MIT</name>
|
268
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
269
|
+
</license>
|
270
|
+
</licenses>
|
271
|
+
</dependency>
|
272
|
+
<dependency>
|
273
|
+
<packageName>webmock</packageName>
|
274
|
+
<version>3.5.1</version>
|
275
|
+
<licenses>
|
276
|
+
<license>
|
277
|
+
<name>MIT</name>
|
278
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
279
|
+
</license>
|
280
|
+
</licenses>
|
281
|
+
</dependency>
|
282
|
+
<dependency>
|
283
|
+
<packageName>with_env</packageName>
|
284
|
+
<version>1.1.0</version>
|
285
|
+
<licenses>
|
286
|
+
<license>
|
287
|
+
<name>MIT</name>
|
288
|
+
<url>http://opensource.org/licenses/mit-license</url>
|
289
|
+
</license>
|
290
|
+
</licenses>
|
291
|
+
</dependency>
|
292
|
+
<dependency>
|
293
|
+
<packageName>xml-simple</packageName>
|
294
|
+
<version>1.1.5</version>
|
295
|
+
<licenses>
|
296
|
+
<license>
|
297
|
+
<name>ruby</name>
|
298
|
+
<url>http://www.ruby-lang.org/en/LICENSE.txt</url>
|
299
|
+
</license>
|
300
|
+
</licenses>
|
301
|
+
</dependency>
|
302
|
+
</dependencies>
|
303
|
+
</licenseSummary>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 3scale_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Cichra
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -87,14 +87,14 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 0.
|
90
|
+
version: 0.6.0
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
97
|
+
version: 0.6.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: cri
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +132,9 @@ executables:
|
|
132
132
|
extensions: []
|
133
133
|
extra_rdoc_files: []
|
134
134
|
files:
|
135
|
+
- 3scale_toolbox.gemspec
|
136
|
+
- LICENSE
|
137
|
+
- NOTICE
|
135
138
|
- README.md
|
136
139
|
- exe/3scale
|
137
140
|
- lib/3scale_toolbox.rb
|
@@ -258,6 +261,7 @@ files:
|
|
258
261
|
- lib/3scale_toolbox/tasks/destroy_mapping_rules_task.rb
|
259
262
|
- lib/3scale_toolbox/tasks/helper_task.rb
|
260
263
|
- lib/3scale_toolbox/version.rb
|
264
|
+
- licenses.xml
|
261
265
|
- resources/swagger_meta_schema.json
|
262
266
|
homepage: https://github.com/3scale/3scale_toolbox
|
263
267
|
licenses:
|