3scale_toolbox 0.15.0 → 0.18.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/3scale_toolbox.gemspec +2 -2
  3. data/README.md +15 -9
  4. data/lib/3scale_toolbox.rb +3 -1
  5. data/lib/3scale_toolbox/3scale_client_factory.rb +3 -4
  6. data/lib/3scale_toolbox/cli.rb +4 -0
  7. data/lib/3scale_toolbox/cli/custom_table_printer.rb +32 -0
  8. data/lib/3scale_toolbox/cli/error_handler.rb +17 -14
  9. data/lib/3scale_toolbox/cli/json_printer.rb +13 -0
  10. data/lib/3scale_toolbox/cli/output_flag.rb +20 -0
  11. data/lib/3scale_toolbox/cli/yaml_printer.rb +13 -0
  12. data/lib/3scale_toolbox/commands.rb +7 -1
  13. data/lib/3scale_toolbox/commands/activedocs_command/apply_command.rb +33 -10
  14. data/lib/3scale_toolbox/commands/activedocs_command/create_command.rb +22 -7
  15. data/lib/3scale_toolbox/commands/activedocs_command/list_command.rb +10 -17
  16. data/lib/3scale_toolbox/commands/application_command/apply_command.rb +27 -4
  17. data/lib/3scale_toolbox/commands/application_command/create_command.rb +16 -1
  18. data/lib/3scale_toolbox/commands/application_command/list_command.rb +10 -13
  19. data/lib/3scale_toolbox/commands/application_command/show_command.rb +8 -14
  20. data/lib/3scale_toolbox/commands/backend_command.rb +22 -0
  21. data/lib/3scale_toolbox/commands/backend_command/copy_command.rb +65 -0
  22. data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_mapping_rules_task.rb +36 -0
  23. data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_methods_task.rb +35 -0
  24. data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb +30 -0
  25. data/lib/3scale_toolbox/commands/backend_command/copy_command/create_or_update_target_backend_task.rb +46 -0
  26. data/lib/3scale_toolbox/commands/backend_command/copy_command/task.rb +67 -0
  27. data/lib/3scale_toolbox/commands/copy_command.rb +2 -2
  28. data/lib/3scale_toolbox/commands/copy_command/service_command.rb +40 -0
  29. data/lib/3scale_toolbox/commands/import_command/issuer_type_transformer.rb +16 -0
  30. data/lib/3scale_toolbox/commands/import_command/openapi.rb +6 -2
  31. data/lib/3scale_toolbox/commands/import_command/openapi/create_mapping_rule_step.rb +2 -1
  32. data/lib/3scale_toolbox/commands/import_command/openapi/create_method_step.rb +5 -14
  33. data/lib/3scale_toolbox/commands/import_command/openapi/step.rb +4 -0
  34. data/lib/3scale_toolbox/commands/import_command/openapi/update_service_proxy_step.rb +1 -0
  35. data/lib/3scale_toolbox/commands/methods_command/apply_command.rb +28 -8
  36. data/lib/3scale_toolbox/commands/methods_command/create_command.rb +23 -3
  37. data/lib/3scale_toolbox/commands/methods_command/delete_command.rb +1 -1
  38. data/lib/3scale_toolbox/commands/methods_command/list_command.rb +7 -13
  39. data/lib/3scale_toolbox/commands/metrics_command/apply_command.rb +26 -4
  40. data/lib/3scale_toolbox/commands/metrics_command/create_command.rb +23 -1
  41. data/lib/3scale_toolbox/commands/metrics_command/list_command.rb +7 -12
  42. data/lib/3scale_toolbox/commands/plans_command/apply_command.rb +36 -7
  43. data/lib/3scale_toolbox/commands/plans_command/create_command.rb +23 -1
  44. data/lib/3scale_toolbox/commands/plans_command/export/read_plan_limits_step.rb +1 -1
  45. data/lib/3scale_toolbox/commands/plans_command/export/read_plan_methods_step.rb +2 -2
  46. data/lib/3scale_toolbox/commands/plans_command/export/read_plan_metrics_step.rb +2 -2
  47. data/lib/3scale_toolbox/commands/plans_command/export/read_plan_pricing_rules_step.rb +1 -2
  48. data/lib/3scale_toolbox/commands/plans_command/export/step.rb +8 -20
  49. data/lib/3scale_toolbox/commands/plans_command/import/import_plan_limits_step.rb +12 -14
  50. data/lib/3scale_toolbox/commands/plans_command/import/import_plan_metrics_step.rb +6 -13
  51. data/lib/3scale_toolbox/commands/plans_command/import/import_plan_pricing_rules_step.rb +12 -20
  52. data/lib/3scale_toolbox/commands/plans_command/import/step.rb +2 -22
  53. data/lib/3scale_toolbox/commands/plans_command/list_command.rb +8 -13
  54. data/lib/3scale_toolbox/commands/plans_command/show_command.rb +7 -15
  55. data/lib/3scale_toolbox/commands/policies_command.rb +24 -0
  56. data/lib/3scale_toolbox/commands/policies_command/export_command.rb +98 -0
  57. data/lib/3scale_toolbox/commands/policies_command/import_command.rb +61 -0
  58. data/lib/3scale_toolbox/commands/product_command.rb +26 -0
  59. data/lib/3scale_toolbox/commands/product_command/copy_command.rb +82 -0
  60. data/lib/3scale_toolbox/commands/product_command/copy_command/copy_backends_task.rb +88 -0
  61. data/lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb +48 -0
  62. data/lib/3scale_toolbox/commands/product_command/export_command.rb +81 -0
  63. data/lib/3scale_toolbox/commands/product_command/import_command.rb +125 -0
  64. data/lib/3scale_toolbox/commands/proxy_config_command.rb +5 -0
  65. data/lib/3scale_toolbox/commands/proxy_config_command/deploy_command.rb +54 -0
  66. data/lib/3scale_toolbox/commands/proxy_config_command/export_command.rb +74 -0
  67. data/lib/3scale_toolbox/commands/proxy_config_command/helper.rb +15 -0
  68. data/lib/3scale_toolbox/commands/proxy_config_command/list_command.rb +13 -29
  69. data/lib/3scale_toolbox/commands/proxy_config_command/show_command.rb +20 -23
  70. data/lib/3scale_toolbox/commands/service_command.rb +7 -5
  71. data/lib/3scale_toolbox/commands/service_command/apply_command.rb +69 -58
  72. data/lib/3scale_toolbox/commands/service_command/copy_command.rb +95 -0
  73. data/lib/3scale_toolbox/commands/service_command/copy_command/bump_proxy_version_task.rb +36 -0
  74. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_activedocs_task.rb +49 -0
  75. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_app_plans_task.rb +35 -0
  76. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_limits_task.rb +38 -0
  77. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_mapping_rules_task.rb +35 -0
  78. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_methods_task.rb +37 -0
  79. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_metrics_task.rb +37 -0
  80. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_policies_task.rb +17 -0
  81. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_pricingrules_task.rb +41 -0
  82. data/lib/3scale_toolbox/commands/service_command/copy_command/copy_service_proxy_task.rb +32 -0
  83. data/lib/3scale_toolbox/commands/service_command/copy_command/create_or_update_service_task.rb +49 -0
  84. data/lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb +38 -0
  85. data/lib/3scale_toolbox/commands/service_command/copy_command/task.rb +85 -0
  86. data/lib/3scale_toolbox/commands/service_command/create_command.rb +58 -44
  87. data/lib/3scale_toolbox/commands/service_command/delete_command.rb +31 -33
  88. data/lib/3scale_toolbox/commands/service_command/list_command.rb +24 -34
  89. data/lib/3scale_toolbox/commands/service_command/show_command.rb +39 -44
  90. data/lib/3scale_toolbox/commands/update_command.rb +3 -3
  91. data/lib/3scale_toolbox/commands/update_command/{update_service.rb → service_command.rb} +22 -18
  92. data/lib/3scale_toolbox/commands/update_command/service_command/copy_service_settings_task.rb +35 -0
  93. data/lib/3scale_toolbox/commands/update_command/service_command/delete_activedocs_task.rb +24 -0
  94. data/lib/3scale_toolbox/crds.rb +16 -0
  95. data/lib/3scale_toolbox/crds/application_plan_dump.rb +19 -0
  96. data/lib/3scale_toolbox/crds/backend_dump.rb +39 -0
  97. data/lib/3scale_toolbox/crds/backend_mapping_rule_dump.rb +26 -0
  98. data/lib/3scale_toolbox/crds/backend_method_dump.rb +12 -0
  99. data/lib/3scale_toolbox/crds/backend_metric_dump.rb +13 -0
  100. data/lib/3scale_toolbox/crds/backend_parser.rb +55 -0
  101. data/lib/3scale_toolbox/crds/backend_usage_dump.rb +11 -0
  102. data/lib/3scale_toolbox/crds/limit_dump.rb +37 -0
  103. data/lib/3scale_toolbox/crds/mapping_rule_dump.rb +26 -0
  104. data/lib/3scale_toolbox/crds/method_dump.rb +12 -0
  105. data/lib/3scale_toolbox/crds/metric_dump.rb +13 -0
  106. data/lib/3scale_toolbox/crds/pricing_rule_dump.rb +38 -0
  107. data/lib/3scale_toolbox/crds/product_deployment_parser.rb +329 -0
  108. data/lib/3scale_toolbox/crds/product_dump.rb +157 -0
  109. data/lib/3scale_toolbox/crds/product_parser.rb +114 -0
  110. data/lib/3scale_toolbox/crds/remote.rb +682 -0
  111. data/lib/3scale_toolbox/entities.rb +8 -0
  112. data/lib/3scale_toolbox/entities/activedocs.rb +12 -0
  113. data/lib/3scale_toolbox/entities/application_plan.rb +74 -39
  114. data/lib/3scale_toolbox/entities/backend.rb +187 -0
  115. data/lib/3scale_toolbox/entities/backend_mapping_rule.rb +102 -0
  116. data/lib/3scale_toolbox/entities/backend_method.rb +99 -0
  117. data/lib/3scale_toolbox/entities/backend_metric.rb +98 -0
  118. data/lib/3scale_toolbox/entities/backend_usage.rb +105 -0
  119. data/lib/3scale_toolbox/entities/limit.rb +71 -0
  120. data/lib/3scale_toolbox/entities/mapping_rule.rb +90 -0
  121. data/lib/3scale_toolbox/entities/method.rb +33 -19
  122. data/lib/3scale_toolbox/entities/metric.rb +29 -18
  123. data/lib/3scale_toolbox/entities/pricing_rule.rb +63 -0
  124. data/lib/3scale_toolbox/entities/proxy_config.rb +0 -1
  125. data/lib/3scale_toolbox/entities/service.rb +166 -48
  126. data/lib/3scale_toolbox/error.rb +53 -0
  127. data/lib/3scale_toolbox/helper.rb +17 -0
  128. data/lib/3scale_toolbox/openapi/oas3.rb +1 -1
  129. data/lib/3scale_toolbox/proxy_logger.rb +5 -1
  130. data/lib/3scale_toolbox/remote_cache.rb +157 -0
  131. data/lib/3scale_toolbox/remotes.rb +2 -2
  132. data/lib/3scale_toolbox/version.rb +1 -1
  133. data/licenses.xml +113 -45
  134. metadata +75 -26
  135. data/lib/3scale_toolbox/commands/copy_command/copy_service.rb +0 -144
  136. data/lib/3scale_toolbox/tasks.rb +0 -15
  137. data/lib/3scale_toolbox/tasks/bump_proxy_version_task.rb +0 -32
  138. data/lib/3scale_toolbox/tasks/copy_activedocs_task.rb +0 -42
  139. data/lib/3scale_toolbox/tasks/copy_app_plans_task.rb +0 -31
  140. data/lib/3scale_toolbox/tasks/copy_limits_task.rb +0 -36
  141. data/lib/3scale_toolbox/tasks/copy_mapping_rules_task.rb +0 -32
  142. data/lib/3scale_toolbox/tasks/copy_methods_task.rb +0 -36
  143. data/lib/3scale_toolbox/tasks/copy_metrics_task.rb +0 -33
  144. data/lib/3scale_toolbox/tasks/copy_policies_task.rb +0 -13
  145. data/lib/3scale_toolbox/tasks/copy_pricingrules_task.rb +0 -41
  146. data/lib/3scale_toolbox/tasks/copy_service_proxy_task.rb +0 -13
  147. data/lib/3scale_toolbox/tasks/copy_service_settings_task.rb +0 -38
  148. data/lib/3scale_toolbox/tasks/copy_task.rb +0 -66
  149. data/lib/3scale_toolbox/tasks/delete_activedocs_task.rb +0 -22
  150. data/lib/3scale_toolbox/tasks/destroy_mapping_rules_task.rb +0 -22
  151. data/lib/3scale_toolbox/tasks/helper_task.rb +0 -25
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.15.0
4
+ version: 0.18.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: 2020-01-14 00:00:00.000000000 Z
12
+ date: 2021-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '10.0'
48
+ version: '13.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '10.0'
55
+ version: '13.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 0.6.0
90
+ version: '1.4'
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.6.0
97
+ version: '1.4'
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,11 +178,19 @@ 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/copy_service.rb
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
193
+ - lib/3scale_toolbox/commands/import_command/issuer_type_transformer.rb
182
194
  - lib/3scale_toolbox/commands/import_command/openapi.rb
183
195
  - lib/3scale_toolbox/commands/import_command/openapi/create_activedocs_step.rb
184
196
  - lib/3scale_toolbox/commands/import_command/openapi/create_mapping_rule_step.rb
@@ -223,9 +235,21 @@ files:
223
235
  - lib/3scale_toolbox/commands/plans_command/import_command.rb
224
236
  - lib/3scale_toolbox/commands/plans_command/list_command.rb
225
237
  - lib/3scale_toolbox/commands/plans_command/show_command.rb
238
+ - lib/3scale_toolbox/commands/policies_command.rb
239
+ - lib/3scale_toolbox/commands/policies_command/export_command.rb
240
+ - lib/3scale_toolbox/commands/policies_command/import_command.rb
226
241
  - lib/3scale_toolbox/commands/policy_registry_command.rb
227
242
  - lib/3scale_toolbox/commands/policy_registry_command/copy_command.rb
243
+ - lib/3scale_toolbox/commands/product_command.rb
244
+ - lib/3scale_toolbox/commands/product_command/copy_command.rb
245
+ - lib/3scale_toolbox/commands/product_command/copy_command/copy_backends_task.rb
246
+ - lib/3scale_toolbox/commands/product_command/copy_command/delete_target_backend_usages_task.rb
247
+ - lib/3scale_toolbox/commands/product_command/export_command.rb
248
+ - lib/3scale_toolbox/commands/product_command/import_command.rb
228
249
  - lib/3scale_toolbox/commands/proxy_config_command.rb
250
+ - lib/3scale_toolbox/commands/proxy_config_command/deploy_command.rb
251
+ - lib/3scale_toolbox/commands/proxy_config_command/export_command.rb
252
+ - lib/3scale_toolbox/commands/proxy_config_command/helper.rb
229
253
  - lib/3scale_toolbox/commands/proxy_config_command/list_command.rb
230
254
  - lib/3scale_toolbox/commands/proxy_config_command/promote_command.rb
231
255
  - lib/3scale_toolbox/commands/proxy_config_command/show_command.rb
@@ -236,21 +260,62 @@ files:
236
260
  - lib/3scale_toolbox/commands/remote_command/remote_rename.rb
237
261
  - lib/3scale_toolbox/commands/service_command.rb
238
262
  - lib/3scale_toolbox/commands/service_command/apply_command.rb
263
+ - lib/3scale_toolbox/commands/service_command/copy_command.rb
264
+ - lib/3scale_toolbox/commands/service_command/copy_command/bump_proxy_version_task.rb
265
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_activedocs_task.rb
266
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_app_plans_task.rb
267
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_limits_task.rb
268
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_mapping_rules_task.rb
269
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_methods_task.rb
270
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_metrics_task.rb
271
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_policies_task.rb
272
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_pricingrules_task.rb
273
+ - lib/3scale_toolbox/commands/service_command/copy_command/copy_service_proxy_task.rb
274
+ - lib/3scale_toolbox/commands/service_command/copy_command/create_or_update_service_task.rb
275
+ - lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb
276
+ - lib/3scale_toolbox/commands/service_command/copy_command/task.rb
239
277
  - lib/3scale_toolbox/commands/service_command/create_command.rb
240
278
  - lib/3scale_toolbox/commands/service_command/delete_command.rb
241
279
  - lib/3scale_toolbox/commands/service_command/list_command.rb
242
280
  - lib/3scale_toolbox/commands/service_command/show_command.rb
243
281
  - lib/3scale_toolbox/commands/update_command.rb
244
- - lib/3scale_toolbox/commands/update_command/update_service.rb
282
+ - lib/3scale_toolbox/commands/update_command/service_command.rb
283
+ - lib/3scale_toolbox/commands/update_command/service_command/copy_service_settings_task.rb
284
+ - lib/3scale_toolbox/commands/update_command/service_command/delete_activedocs_task.rb
245
285
  - lib/3scale_toolbox/configuration.rb
286
+ - lib/3scale_toolbox/crds.rb
287
+ - lib/3scale_toolbox/crds/application_plan_dump.rb
288
+ - lib/3scale_toolbox/crds/backend_dump.rb
289
+ - lib/3scale_toolbox/crds/backend_mapping_rule_dump.rb
290
+ - lib/3scale_toolbox/crds/backend_method_dump.rb
291
+ - lib/3scale_toolbox/crds/backend_metric_dump.rb
292
+ - lib/3scale_toolbox/crds/backend_parser.rb
293
+ - lib/3scale_toolbox/crds/backend_usage_dump.rb
294
+ - lib/3scale_toolbox/crds/limit_dump.rb
295
+ - lib/3scale_toolbox/crds/mapping_rule_dump.rb
296
+ - lib/3scale_toolbox/crds/method_dump.rb
297
+ - lib/3scale_toolbox/crds/metric_dump.rb
298
+ - lib/3scale_toolbox/crds/pricing_rule_dump.rb
299
+ - lib/3scale_toolbox/crds/product_deployment_parser.rb
300
+ - lib/3scale_toolbox/crds/product_dump.rb
301
+ - lib/3scale_toolbox/crds/product_parser.rb
302
+ - lib/3scale_toolbox/crds/remote.rb
246
303
  - lib/3scale_toolbox/entities.rb
247
304
  - lib/3scale_toolbox/entities/account.rb
248
305
  - lib/3scale_toolbox/entities/activedocs.rb
249
306
  - lib/3scale_toolbox/entities/application.rb
250
307
  - lib/3scale_toolbox/entities/application_plan.rb
308
+ - lib/3scale_toolbox/entities/backend.rb
309
+ - lib/3scale_toolbox/entities/backend_mapping_rule.rb
310
+ - lib/3scale_toolbox/entities/backend_method.rb
311
+ - lib/3scale_toolbox/entities/backend_metric.rb
312
+ - lib/3scale_toolbox/entities/backend_usage.rb
251
313
  - lib/3scale_toolbox/entities/base_entity.rb
314
+ - lib/3scale_toolbox/entities/limit.rb
315
+ - lib/3scale_toolbox/entities/mapping_rule.rb
252
316
  - lib/3scale_toolbox/entities/method.rb
253
317
  - lib/3scale_toolbox/entities/metric.rb
318
+ - lib/3scale_toolbox/entities/pricing_rule.rb
254
319
  - lib/3scale_toolbox/entities/proxy_config.rb
255
320
  - lib/3scale_toolbox/entities/service.rb
256
321
  - lib/3scale_toolbox/error.rb
@@ -259,24 +324,9 @@ files:
259
324
  - lib/3scale_toolbox/openapi/oas3.rb
260
325
  - lib/3scale_toolbox/openapi/swagger.rb
261
326
  - lib/3scale_toolbox/proxy_logger.rb
327
+ - lib/3scale_toolbox/remote_cache.rb
262
328
  - lib/3scale_toolbox/remotes.rb
263
329
  - 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
330
  - lib/3scale_toolbox/version.rb
281
331
  - licenses.xml
282
332
  - resources/oas3_meta_schema.json
@@ -300,8 +350,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
350
  - !ruby/object:Gem::Version
301
351
  version: '0'
302
352
  requirements: []
303
- rubyforge_project:
304
- rubygems_version: 2.7.6
353
+ rubygems_version: 3.1.2
305
354
  signing_key:
306
355
  specification_version: 4
307
356
  summary: 3scale Toolbox.
@@ -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
@@ -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