3scale_toolbox 0.15.0 → 0.16.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 +4 -4
- data/3scale_toolbox.gemspec +1 -1
- data/README.md +4 -1
- data/lib/3scale_toolbox.rb +0 -1
- data/lib/3scale_toolbox/cli.rb +4 -0
- data/lib/3scale_toolbox/cli/custom_table_printer.rb +32 -0
- data/lib/3scale_toolbox/cli/json_printer.rb +13 -0
- data/lib/3scale_toolbox/cli/output_flag.rb +20 -0
- data/lib/3scale_toolbox/cli/yaml_printer.rb +13 -0
- data/lib/3scale_toolbox/commands.rb +5 -1
- data/lib/3scale_toolbox/commands/activedocs_command/apply_command.rb +33 -10
- data/lib/3scale_toolbox/commands/activedocs_command/create_command.rb +22 -7
- data/lib/3scale_toolbox/commands/activedocs_command/list_command.rb +10 -17
- data/lib/3scale_toolbox/commands/application_command/apply_command.rb +27 -4
- data/lib/3scale_toolbox/commands/application_command/create_command.rb +16 -1
- data/lib/3scale_toolbox/commands/application_command/list_command.rb +10 -13
- data/lib/3scale_toolbox/commands/application_command/show_command.rb +8 -14
- data/lib/3scale_toolbox/commands/backend_command.rb +22 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command.rb +65 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_mapping_rules_task.rb +52 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_methods_task.rb +40 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb +30 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command/create_or_update_target_backend_task.rb +45 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command/task.rb +89 -0
- data/lib/3scale_toolbox/commands/copy_command.rb +2 -2
- data/lib/3scale_toolbox/commands/copy_command/service_command.rb +40 -0
- data/lib/3scale_toolbox/commands/import_command/openapi.rb +3 -2
- data/lib/3scale_toolbox/commands/methods_command/apply_command.rb +26 -4
- data/lib/3scale_toolbox/commands/methods_command/create_command.rb +23 -1
- data/lib/3scale_toolbox/commands/methods_command/list_command.rb +11 -9
- data/lib/3scale_toolbox/commands/metrics_command/apply_command.rb +26 -4
- data/lib/3scale_toolbox/commands/metrics_command/create_command.rb +23 -1
- data/lib/3scale_toolbox/commands/metrics_command/list_command.rb +7 -12
- data/lib/3scale_toolbox/commands/plans_command/apply_command.rb +36 -7
- data/lib/3scale_toolbox/commands/plans_command/create_command.rb +23 -1
- data/lib/3scale_toolbox/commands/plans_command/list_command.rb +8 -13
- data/lib/3scale_toolbox/commands/plans_command/show_command.rb +6 -14
- data/lib/3scale_toolbox/commands/product_command.rb +22 -0
- data/lib/3scale_toolbox/commands/product_command/copy_command.rb +78 -0
- data/lib/3scale_toolbox/commands/product_command/copy_command/copy_backends_task.rb +71 -0
- data/lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb +48 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/list_command.rb +13 -29
- data/lib/3scale_toolbox/commands/proxy_config_command/show_command.rb +20 -23
- data/lib/3scale_toolbox/commands/service_command.rb +7 -5
- data/lib/3scale_toolbox/commands/service_command/apply_command.rb +69 -58
- data/lib/3scale_toolbox/commands/service_command/copy_command.rb +95 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/bump_proxy_version_task.rb +36 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_activedocs_task.rb +46 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_app_plans_task.rb +35 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_limits_task.rb +39 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_mapping_rules_task.rb +35 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_methods_task.rb +40 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_metrics_task.rb +37 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_policies_task.rb +17 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_pricingrules_task.rb +44 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_service_proxy_task.rb +17 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/create_or_update_service_task.rb +48 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb +34 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/task.rb +99 -0
- data/lib/3scale_toolbox/commands/service_command/create_command.rb +58 -44
- data/lib/3scale_toolbox/commands/service_command/delete_command.rb +31 -33
- data/lib/3scale_toolbox/commands/service_command/list_command.rb +24 -34
- data/lib/3scale_toolbox/commands/service_command/show_command.rb +39 -44
- data/lib/3scale_toolbox/commands/update_command.rb +2 -2
- data/lib/3scale_toolbox/commands/update_command/{update_service.rb → service_command.rb} +19 -16
- data/lib/3scale_toolbox/commands/update_command/service_command/copy_service_settings_task.rb +35 -0
- data/lib/3scale_toolbox/commands/update_command/service_command/delete_activedocs_task.rb +26 -0
- data/lib/3scale_toolbox/entities.rb +5 -0
- data/lib/3scale_toolbox/entities/backend.rb +152 -0
- data/lib/3scale_toolbox/entities/backend_mapping_rule.rb +76 -0
- data/lib/3scale_toolbox/entities/backend_method.rb +90 -0
- data/lib/3scale_toolbox/entities/backend_metric.rb +88 -0
- data/lib/3scale_toolbox/entities/backend_usage.rb +99 -0
- data/lib/3scale_toolbox/entities/service.rb +18 -3
- data/lib/3scale_toolbox/error.rb +3 -0
- data/lib/3scale_toolbox/helper.rb +20 -0
- data/lib/3scale_toolbox/proxy_logger.rb +1 -1
- data/lib/3scale_toolbox/version.rb +1 -1
- data/licenses.xml +3 -3
- metadata +42 -22
- data/lib/3scale_toolbox/commands/copy_command/copy_service.rb +0 -144
- data/lib/3scale_toolbox/tasks.rb +0 -15
- data/lib/3scale_toolbox/tasks/bump_proxy_version_task.rb +0 -32
- data/lib/3scale_toolbox/tasks/copy_activedocs_task.rb +0 -42
- data/lib/3scale_toolbox/tasks/copy_app_plans_task.rb +0 -31
- data/lib/3scale_toolbox/tasks/copy_limits_task.rb +0 -36
- data/lib/3scale_toolbox/tasks/copy_mapping_rules_task.rb +0 -32
- data/lib/3scale_toolbox/tasks/copy_methods_task.rb +0 -36
- data/lib/3scale_toolbox/tasks/copy_metrics_task.rb +0 -33
- data/lib/3scale_toolbox/tasks/copy_policies_task.rb +0 -13
- data/lib/3scale_toolbox/tasks/copy_pricingrules_task.rb +0 -41
- data/lib/3scale_toolbox/tasks/copy_service_proxy_task.rb +0 -13
- data/lib/3scale_toolbox/tasks/copy_service_settings_task.rb +0 -38
- data/lib/3scale_toolbox/tasks/copy_task.rb +0 -66
- data/lib/3scale_toolbox/tasks/delete_activedocs_task.rb +0 -22
- data/lib/3scale_toolbox/tasks/destroy_mapping_rules_task.rb +0 -22
- data/lib/3scale_toolbox/tasks/helper_task.rb +0 -25
data/licenses.xml
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<dependencies>
|
|
4
4
|
<dependency>
|
|
5
5
|
<packageName>3scale-api</packageName>
|
|
6
|
-
<version>0.
|
|
6
|
+
<version>1.0.0</version>
|
|
7
7
|
<licenses>
|
|
8
8
|
<license>
|
|
9
9
|
<name>MIT</name>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</dependency>
|
|
14
14
|
<dependency>
|
|
15
15
|
<packageName>3scale_toolbox</packageName>
|
|
16
|
-
<version>0.
|
|
16
|
+
<version>0.16.0</version>
|
|
17
17
|
<licenses>
|
|
18
18
|
<license>
|
|
19
19
|
<name>MIT</name>
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
</dependency>
|
|
94
94
|
<dependency>
|
|
95
95
|
<packageName>cri</packageName>
|
|
96
|
-
<version>2.15.
|
|
96
|
+
<version>2.15.10</version>
|
|
97
97
|
<licenses>
|
|
98
98
|
<license>
|
|
99
99
|
<name>MIT</name>
|
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.16.0
|
|
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: 2020-
|
|
12
|
+
date: 2020-02-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:
|
|
90
|
+
version: '1.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:
|
|
97
|
+
version: '1.0'
|
|
98
98
|
- !ruby/object:Gem::Dependency
|
|
99
99
|
name: cri
|
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -158,7 +158,11 @@ files:
|
|
|
158
158
|
- lib/3scale_toolbox/attribute_filters/service_id_from_ref_filter.rb
|
|
159
159
|
- lib/3scale_toolbox/base_command.rb
|
|
160
160
|
- lib/3scale_toolbox/cli.rb
|
|
161
|
+
- lib/3scale_toolbox/cli/custom_table_printer.rb
|
|
161
162
|
- lib/3scale_toolbox/cli/error_handler.rb
|
|
163
|
+
- lib/3scale_toolbox/cli/json_printer.rb
|
|
164
|
+
- lib/3scale_toolbox/cli/output_flag.rb
|
|
165
|
+
- lib/3scale_toolbox/cli/yaml_printer.rb
|
|
162
166
|
- lib/3scale_toolbox/commands.rb
|
|
163
167
|
- lib/3scale_toolbox/commands/3scale_command.rb
|
|
164
168
|
- lib/3scale_toolbox/commands/account_command.rb
|
|
@@ -174,8 +178,15 @@ files:
|
|
|
174
178
|
- lib/3scale_toolbox/commands/application_command/delete_command.rb
|
|
175
179
|
- lib/3scale_toolbox/commands/application_command/list_command.rb
|
|
176
180
|
- lib/3scale_toolbox/commands/application_command/show_command.rb
|
|
181
|
+
- lib/3scale_toolbox/commands/backend_command.rb
|
|
182
|
+
- lib/3scale_toolbox/commands/backend_command/copy_command.rb
|
|
183
|
+
- lib/3scale_toolbox/commands/backend_command/copy_command/copy_mapping_rules_task.rb
|
|
184
|
+
- lib/3scale_toolbox/commands/backend_command/copy_command/copy_methods_task.rb
|
|
185
|
+
- lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
|
|
186
|
+
- lib/3scale_toolbox/commands/backend_command/copy_command/create_or_update_target_backend_task.rb
|
|
187
|
+
- lib/3scale_toolbox/commands/backend_command/copy_command/task.rb
|
|
177
188
|
- lib/3scale_toolbox/commands/copy_command.rb
|
|
178
|
-
- lib/3scale_toolbox/commands/copy_command/
|
|
189
|
+
- lib/3scale_toolbox/commands/copy_command/service_command.rb
|
|
179
190
|
- lib/3scale_toolbox/commands/help_command.rb
|
|
180
191
|
- lib/3scale_toolbox/commands/import_command.rb
|
|
181
192
|
- lib/3scale_toolbox/commands/import_command/import_csv.rb
|
|
@@ -225,6 +236,10 @@ files:
|
|
|
225
236
|
- lib/3scale_toolbox/commands/plans_command/show_command.rb
|
|
226
237
|
- lib/3scale_toolbox/commands/policy_registry_command.rb
|
|
227
238
|
- lib/3scale_toolbox/commands/policy_registry_command/copy_command.rb
|
|
239
|
+
- lib/3scale_toolbox/commands/product_command.rb
|
|
240
|
+
- lib/3scale_toolbox/commands/product_command/copy_command.rb
|
|
241
|
+
- lib/3scale_toolbox/commands/product_command/copy_command/copy_backends_task.rb
|
|
242
|
+
- lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
|
|
228
243
|
- lib/3scale_toolbox/commands/proxy_config_command.rb
|
|
229
244
|
- lib/3scale_toolbox/commands/proxy_config_command/list_command.rb
|
|
230
245
|
- lib/3scale_toolbox/commands/proxy_config_command/promote_command.rb
|
|
@@ -236,18 +251,39 @@ files:
|
|
|
236
251
|
- lib/3scale_toolbox/commands/remote_command/remote_rename.rb
|
|
237
252
|
- lib/3scale_toolbox/commands/service_command.rb
|
|
238
253
|
- lib/3scale_toolbox/commands/service_command/apply_command.rb
|
|
254
|
+
- lib/3scale_toolbox/commands/service_command/copy_command.rb
|
|
255
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/bump_proxy_version_task.rb
|
|
256
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_activedocs_task.rb
|
|
257
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_app_plans_task.rb
|
|
258
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_limits_task.rb
|
|
259
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_mapping_rules_task.rb
|
|
260
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_methods_task.rb
|
|
261
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_metrics_task.rb
|
|
262
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_policies_task.rb
|
|
263
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_pricingrules_task.rb
|
|
264
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/copy_service_proxy_task.rb
|
|
265
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/create_or_update_service_task.rb
|
|
266
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
|
|
267
|
+
- lib/3scale_toolbox/commands/service_command/copy_command/task.rb
|
|
239
268
|
- lib/3scale_toolbox/commands/service_command/create_command.rb
|
|
240
269
|
- lib/3scale_toolbox/commands/service_command/delete_command.rb
|
|
241
270
|
- lib/3scale_toolbox/commands/service_command/list_command.rb
|
|
242
271
|
- lib/3scale_toolbox/commands/service_command/show_command.rb
|
|
243
272
|
- lib/3scale_toolbox/commands/update_command.rb
|
|
244
|
-
- lib/3scale_toolbox/commands/update_command/
|
|
273
|
+
- lib/3scale_toolbox/commands/update_command/service_command.rb
|
|
274
|
+
- lib/3scale_toolbox/commands/update_command/service_command/copy_service_settings_task.rb
|
|
275
|
+
- lib/3scale_toolbox/commands/update_command/service_command/delete_activedocs_task.rb
|
|
245
276
|
- lib/3scale_toolbox/configuration.rb
|
|
246
277
|
- lib/3scale_toolbox/entities.rb
|
|
247
278
|
- lib/3scale_toolbox/entities/account.rb
|
|
248
279
|
- lib/3scale_toolbox/entities/activedocs.rb
|
|
249
280
|
- lib/3scale_toolbox/entities/application.rb
|
|
250
281
|
- lib/3scale_toolbox/entities/application_plan.rb
|
|
282
|
+
- lib/3scale_toolbox/entities/backend.rb
|
|
283
|
+
- lib/3scale_toolbox/entities/backend_mapping_rule.rb
|
|
284
|
+
- lib/3scale_toolbox/entities/backend_method.rb
|
|
285
|
+
- lib/3scale_toolbox/entities/backend_metric.rb
|
|
286
|
+
- lib/3scale_toolbox/entities/backend_usage.rb
|
|
251
287
|
- lib/3scale_toolbox/entities/base_entity.rb
|
|
252
288
|
- lib/3scale_toolbox/entities/method.rb
|
|
253
289
|
- lib/3scale_toolbox/entities/metric.rb
|
|
@@ -261,22 +297,6 @@ files:
|
|
|
261
297
|
- lib/3scale_toolbox/proxy_logger.rb
|
|
262
298
|
- lib/3scale_toolbox/remotes.rb
|
|
263
299
|
- lib/3scale_toolbox/resource_reader.rb
|
|
264
|
-
- lib/3scale_toolbox/tasks.rb
|
|
265
|
-
- lib/3scale_toolbox/tasks/bump_proxy_version_task.rb
|
|
266
|
-
- lib/3scale_toolbox/tasks/copy_activedocs_task.rb
|
|
267
|
-
- lib/3scale_toolbox/tasks/copy_app_plans_task.rb
|
|
268
|
-
- lib/3scale_toolbox/tasks/copy_limits_task.rb
|
|
269
|
-
- lib/3scale_toolbox/tasks/copy_mapping_rules_task.rb
|
|
270
|
-
- lib/3scale_toolbox/tasks/copy_methods_task.rb
|
|
271
|
-
- lib/3scale_toolbox/tasks/copy_metrics_task.rb
|
|
272
|
-
- lib/3scale_toolbox/tasks/copy_policies_task.rb
|
|
273
|
-
- lib/3scale_toolbox/tasks/copy_pricingrules_task.rb
|
|
274
|
-
- lib/3scale_toolbox/tasks/copy_service_proxy_task.rb
|
|
275
|
-
- lib/3scale_toolbox/tasks/copy_service_settings_task.rb
|
|
276
|
-
- lib/3scale_toolbox/tasks/copy_task.rb
|
|
277
|
-
- lib/3scale_toolbox/tasks/delete_activedocs_task.rb
|
|
278
|
-
- lib/3scale_toolbox/tasks/destroy_mapping_rules_task.rb
|
|
279
|
-
- lib/3scale_toolbox/tasks/helper_task.rb
|
|
280
300
|
- lib/3scale_toolbox/version.rb
|
|
281
301
|
- licenses.xml
|
|
282
302
|
- resources/oas3_meta_schema.json
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
module ThreeScaleToolbox
|
|
2
|
-
module Commands
|
|
3
|
-
module CopyCommand
|
|
4
|
-
class CopyServiceSubcommand < Cri::CommandRunner
|
|
5
|
-
include ThreeScaleToolbox::Command
|
|
6
|
-
|
|
7
|
-
def self.command
|
|
8
|
-
Cri::Command.define do
|
|
9
|
-
name 'service'
|
|
10
|
-
usage 'service [opts] -s <src> -d <dst> <source-service>'
|
|
11
|
-
summary 'copy service'
|
|
12
|
-
description <<-HEREDOC
|
|
13
|
-
This command makes a copy of the referenced service.
|
|
14
|
-
Target service will be searched by source service system name. System name can be overriden with `--target_system_name` option.
|
|
15
|
-
If a service with the selected `system_name` is not found, it will be created.
|
|
16
|
-
\n Components of the service being copied:
|
|
17
|
-
\nservice settings
|
|
18
|
-
\nproxy settings
|
|
19
|
-
\npricing rules
|
|
20
|
-
\nactivedocs
|
|
21
|
-
\nmetrics
|
|
22
|
-
\nmethods
|
|
23
|
-
\napplication plans
|
|
24
|
-
\nmapping rules
|
|
25
|
-
HEREDOC
|
|
26
|
-
|
|
27
|
-
option :s, :source, '3scale source instance. Url or remote name', argument: :required
|
|
28
|
-
option :d, :destination, '3scale target instance. Url or remote name', argument: :required
|
|
29
|
-
option :t, 'target_system_name', 'Target system name. Default to source system name', argument: :required
|
|
30
|
-
flag :f, :force, 'Overwrites the mapping rules by deleting all rules from target service first'
|
|
31
|
-
flag :r, 'rules-only', 'Only mapping rules are copied'
|
|
32
|
-
param :source_service
|
|
33
|
-
|
|
34
|
-
runner CopyServiceSubcommand
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def run
|
|
39
|
-
target_service = Entities::Service.find(remote: target_remote,
|
|
40
|
-
ref: target_service_ref)
|
|
41
|
-
|
|
42
|
-
target_service_new = target_service.nil?
|
|
43
|
-
if target_service_new
|
|
44
|
-
target_service = Entities::Service.create(remote: target_remote,
|
|
45
|
-
service_params: create_service_attrs)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
if target_service == source_service
|
|
49
|
-
raise ThreeScaleToolbox::Error, 'Source and destination services are the same: ' \
|
|
50
|
-
"ID: #{source_service.id} system_name: #{source_service.attrs['system_name']}"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
puts "new service id #{target_service.id}"
|
|
54
|
-
|
|
55
|
-
context = create_context(source_service, target_service)
|
|
56
|
-
|
|
57
|
-
tasks = []
|
|
58
|
-
unless option_rules_only
|
|
59
|
-
tasks << Tasks::CopyServiceSettingsTask.new(context)
|
|
60
|
-
tasks << Tasks::CopyServiceProxyTask.new(context)
|
|
61
|
-
tasks << Tasks::CopyMethodsTask.new(context)
|
|
62
|
-
tasks << Tasks::CopyMetricsTask.new(context)
|
|
63
|
-
tasks << Tasks::CopyApplicationPlansTask.new(context)
|
|
64
|
-
tasks << Tasks::CopyLimitsTask.new(context)
|
|
65
|
-
tasks << Tasks::CopyPoliciesTask.new(context)
|
|
66
|
-
tasks << Tasks::CopyPricingRulesTask.new(context)
|
|
67
|
-
tasks << Tasks::CopyActiveDocsTask.new(context)
|
|
68
|
-
end
|
|
69
|
-
tasks << Tasks::DestroyMappingRulesTask.new(context) if option_force || target_service_new
|
|
70
|
-
tasks << Tasks::CopyMappingRulesTask.new(context)
|
|
71
|
-
tasks.each(&:call)
|
|
72
|
-
|
|
73
|
-
# This should be the last step
|
|
74
|
-
Tasks::BumpProxyVersionTask.new(service: target_service).call
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
private
|
|
78
|
-
|
|
79
|
-
def create_context(source, target)
|
|
80
|
-
{
|
|
81
|
-
source: source,
|
|
82
|
-
target: target
|
|
83
|
-
}
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def option_rules_only
|
|
87
|
-
options[:'rules-only']
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def option_force
|
|
91
|
-
options[:force]
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def option_target_system_name
|
|
95
|
-
options[:target_system_name]
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def create_service_attrs
|
|
99
|
-
# minimum required attrs.
|
|
100
|
-
# Service settings will be updated in later task
|
|
101
|
-
# These attrs are only when service is created
|
|
102
|
-
{
|
|
103
|
-
'name' => source_service.attrs.fetch('name'),
|
|
104
|
-
'system_name' => target_service_ref
|
|
105
|
-
}.compact
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def source_service
|
|
109
|
-
@source_service ||= find_source_service
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def find_source_service
|
|
113
|
-
Entities::Service.find(remote: source_remote, ref: source_service_ref).tap do |svc|
|
|
114
|
-
raise ThreeScaleToolbox::Error, "Service #{source_service_ref} does not exist" if svc.nil?
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def source_remote
|
|
119
|
-
@source_remote ||= threescale_client(source)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def target_remote
|
|
123
|
-
@target_remote ||= threescale_client(target)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def source_service_ref
|
|
127
|
-
arguments[:source_service]
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def target_service_ref
|
|
131
|
-
option_target_system_name || source_service.attrs.fetch('system_name')
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def source
|
|
135
|
-
fetch_required_option(:source)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def target
|
|
139
|
-
fetch_required_option(:destination)
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
data/lib/3scale_toolbox/tasks.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require '3scale_toolbox/tasks/copy_task'
|
|
2
|
-
require '3scale_toolbox/tasks/helper_task'
|
|
3
|
-
require '3scale_toolbox/tasks/copy_service_proxy_task'
|
|
4
|
-
require '3scale_toolbox/tasks/copy_metrics_task'
|
|
5
|
-
require '3scale_toolbox/tasks/copy_methods_task'
|
|
6
|
-
require '3scale_toolbox/tasks/copy_app_plans_task'
|
|
7
|
-
require '3scale_toolbox/tasks/copy_limits_task'
|
|
8
|
-
require '3scale_toolbox/tasks/destroy_mapping_rules_task'
|
|
9
|
-
require '3scale_toolbox/tasks/copy_mapping_rules_task'
|
|
10
|
-
require '3scale_toolbox/tasks/copy_service_settings_task'
|
|
11
|
-
require '3scale_toolbox/tasks/copy_policies_task'
|
|
12
|
-
require '3scale_toolbox/tasks/copy_pricingrules_task'
|
|
13
|
-
require '3scale_toolbox/tasks/delete_activedocs_task'
|
|
14
|
-
require '3scale_toolbox/tasks/copy_activedocs_task'
|
|
15
|
-
require '3scale_toolbox/tasks/bump_proxy_version_task'
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module ThreeScaleToolbox
|
|
2
|
-
module Tasks
|
|
3
|
-
class BumpProxyVersionTask
|
|
4
|
-
attr_reader :service
|
|
5
|
-
|
|
6
|
-
def initialize(service:)
|
|
7
|
-
@service = service
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
# bumps proxy config version to propagate proxy settings updates
|
|
12
|
-
def call
|
|
13
|
-
# Proxy update is the mechanism to increase version of the proxy,
|
|
14
|
-
# Hence propagating (mapping rules, poicies, oidc, auth) update to
|
|
15
|
-
# latest proxy config, making available to gateway.
|
|
16
|
-
|
|
17
|
-
# Currently it is done always because mapping rules, at least, are always created
|
|
18
|
-
# So they need to be propagated
|
|
19
|
-
proxy_settings = {
|
|
20
|
-
# Adding harmless attribute to avoid empty body
|
|
21
|
-
# update_proxy cannot be done with empty body
|
|
22
|
-
# and must be done to increase proxy version
|
|
23
|
-
# If proxy settings have not been changed since last update,
|
|
24
|
-
# this request will not have effect and proxy config version will not be bumped.
|
|
25
|
-
service_id: service.id
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
service.update_proxy proxy_settings
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
module ThreeScaleToolbox
|
|
2
|
-
module Tasks
|
|
3
|
-
class CopyActiveDocsTask
|
|
4
|
-
include CopyTask
|
|
5
|
-
|
|
6
|
-
def call
|
|
7
|
-
puts 'copying all service ActiveDocs'
|
|
8
|
-
|
|
9
|
-
source.activedocs.each(&method(:apply_target_activedoc))
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
def apply_target_activedoc(attrs)
|
|
15
|
-
activedocs = Entities::ActiveDocs.find_by_system_name(remote: target.remote,
|
|
16
|
-
system_name: attrs['system_name'])
|
|
17
|
-
if activedocs.nil?
|
|
18
|
-
Entities::ActiveDocs.create(remote: target.remote, attrs: create_attrs(attrs))
|
|
19
|
-
elsif activedocs.attrs.fetch('service_id') == target.id
|
|
20
|
-
activedocs.update(update_attrs(attrs))
|
|
21
|
-
else
|
|
22
|
-
# activedocs with same system_name exists, but now owned by target service
|
|
23
|
-
new_attrs = create_attrs(attrs)
|
|
24
|
-
new_attrs['system_name'] = "#{attrs['system_name']}#{target.id}"
|
|
25
|
-
Entities::ActiveDocs.create(remote: target.remote, attrs: new_attrs)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def update_attrs(old_attrs)
|
|
30
|
-
create_attrs(old_attrs)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def create_attrs(old_attrs)
|
|
34
|
-
# keep same system_name
|
|
35
|
-
new_attrs = old_attrs.reject { |key, _| %w[id created_at updated_at].include? key }
|
|
36
|
-
new_attrs.tap do |attrs|
|
|
37
|
-
attrs['service_id'] = target.id
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
module ThreeScaleToolbox
|
|
2
|
-
module Tasks
|
|
3
|
-
class CopyApplicationPlansTask
|
|
4
|
-
include CopyTask
|
|
5
|
-
|
|
6
|
-
def call
|
|
7
|
-
source_plans = source.plans
|
|
8
|
-
target_plans = target.plans
|
|
9
|
-
missing_plans = missing_app_plans(source_plans, target_plans)
|
|
10
|
-
missing_plans.each do |plan|
|
|
11
|
-
plan.delete('links')
|
|
12
|
-
plan.delete('default') # TODO: handle default plan
|
|
13
|
-
if plan.delete('custom') # TODO: what to do with custom plans?
|
|
14
|
-
puts "skipping custom plan #{plan}"
|
|
15
|
-
else
|
|
16
|
-
ThreeScaleToolbox::Entities::ApplicationPlan.create(service: target, plan_attrs: plan)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
puts "target service missing #{missing_plans.size} application plans"
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def missing_app_plans(source_plans, target_plans)
|
|
25
|
-
ThreeScaleToolbox::Helper.array_difference(source_plans, target_plans) do |src, target|
|
|
26
|
-
ThreeScaleToolbox::Helper.compare_hashes(src, target, ['system_name'])
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module ThreeScaleToolbox
|
|
2
|
-
module Tasks
|
|
3
|
-
class CopyLimitsTask
|
|
4
|
-
include CopyTask
|
|
5
|
-
include Helper
|
|
6
|
-
|
|
7
|
-
def call
|
|
8
|
-
plan_mapping = application_plan_mapping(source.plans, target.plans)
|
|
9
|
-
plan_mapping.each do |plan_id, target_plan|
|
|
10
|
-
source_plan = ThreeScaleToolbox::Entities::ApplicationPlan.new(id: plan_id, service: source)
|
|
11
|
-
target_plan = ThreeScaleToolbox::Entities::ApplicationPlan.new(id: target_plan['id'], service: target)
|
|
12
|
-
missing_limits = missing_limits(source_plan.limits, target_plan.limits, metrics_map)
|
|
13
|
-
missing_limits.each do |limit|
|
|
14
|
-
limit.delete('links')
|
|
15
|
-
target_plan.create_limit(metrics_map.fetch(limit.fetch('metric_id')), limit)
|
|
16
|
-
end
|
|
17
|
-
puts "Missing #{missing_limits.size} plan limits from target application plan " \
|
|
18
|
-
"#{target_plan.id}. Source plan #{plan_id}"
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def metrics_map
|
|
25
|
-
@metrics_map ||= metrics_mapping(source_metrics_and_methods, target_metrics_and_methods)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def missing_limits(source_limits, target_limits, metrics_map)
|
|
29
|
-
ThreeScaleToolbox::Helper.array_difference(source_limits, target_limits) do |limit, target|
|
|
30
|
-
ThreeScaleToolbox::Helper.compare_hashes(limit, target, ['period']) &&
|
|
31
|
-
metrics_map.fetch(limit.fetch('metric_id')) == target.fetch('metric_id')
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|