3scale_toolbox 0.9.0 → 0.10.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -23
  3. data/lib/3scale_toolbox/base_command.rb +0 -1
  4. data/lib/3scale_toolbox/commands.rb +4 -0
  5. data/lib/3scale_toolbox/commands/copy_command/copy_service.rb +1 -1
  6. data/lib/3scale_toolbox/commands/import_command/openapi/create_activedocs_step.rb +2 -2
  7. data/lib/3scale_toolbox/commands/import_command/openapi/create_method_step.rb +21 -15
  8. data/lib/3scale_toolbox/commands/import_command/openapi/create_service_step.rb +10 -13
  9. data/lib/3scale_toolbox/commands/methods_command.rb +28 -0
  10. data/lib/3scale_toolbox/commands/methods_command/apply_command.rb +101 -0
  11. data/lib/3scale_toolbox/commands/methods_command/create_command.rb +73 -0
  12. data/lib/3scale_toolbox/commands/methods_command/delete_command.rb +67 -0
  13. data/lib/3scale_toolbox/commands/methods_command/list_command.rb +64 -0
  14. data/lib/3scale_toolbox/commands/metrics_command.rb +28 -0
  15. data/lib/3scale_toolbox/commands/metrics_command/apply_command.rb +102 -0
  16. data/lib/3scale_toolbox/commands/metrics_command/create_command.rb +77 -0
  17. data/lib/3scale_toolbox/commands/metrics_command/delete_command.rb +66 -0
  18. data/lib/3scale_toolbox/commands/metrics_command/list_command.rb +70 -0
  19. data/lib/3scale_toolbox/commands/plans_command/create_command.rb +1 -1
  20. data/lib/3scale_toolbox/commands/plans_command/export/read_app_plan_step.rb +1 -1
  21. data/lib/3scale_toolbox/commands/plans_command/export/step.rb +5 -1
  22. data/lib/3scale_toolbox/commands/plans_command/import/import_plan_metrics_step.rb +7 -13
  23. data/lib/3scale_toolbox/commands/plans_command/import/step.rb +2 -8
  24. data/lib/3scale_toolbox/commands/plans_command/show_command.rb +1 -1
  25. data/lib/3scale_toolbox/commands/remote_command/remote_add.rb +1 -1
  26. data/lib/3scale_toolbox/entities.rb +2 -0
  27. data/lib/3scale_toolbox/entities/application_plan.rb +47 -14
  28. data/lib/3scale_toolbox/entities/method.rb +80 -0
  29. data/lib/3scale_toolbox/entities/metric.rb +113 -0
  30. data/lib/3scale_toolbox/entities/service.rb +112 -38
  31. data/lib/3scale_toolbox/error.rb +13 -0
  32. data/lib/3scale_toolbox/tasks/copy_activedocs_task.rb +1 -1
  33. data/lib/3scale_toolbox/tasks/copy_methods_task.rb +11 -8
  34. data/lib/3scale_toolbox/tasks/copy_metrics_task.rb +1 -1
  35. data/lib/3scale_toolbox/tasks/copy_service_proxy_task.rb +1 -1
  36. data/lib/3scale_toolbox/tasks/delete_activedocs_task.rb +1 -1
  37. data/lib/3scale_toolbox/tasks/update_service_settings_task.rb +3 -3
  38. data/lib/3scale_toolbox/version.rb +1 -1
  39. metadata +16 -4
@@ -5,4 +5,17 @@ module ThreeScaleToolbox
5
5
 
6
6
  class InvalidUrlError < Error
7
7
  end
8
+
9
+ class ThreeScaleApiError < Error
10
+ attr_reader :apierrors
11
+
12
+ def initialize(msg = '', apierrors = {})
13
+ @apierrors = apierrors
14
+ super(msg)
15
+ end
16
+
17
+ def message
18
+ "#{super}. Errors: #{apierrors}"
19
+ end
20
+ end
8
21
  end
@@ -6,7 +6,7 @@ module ThreeScaleToolbox
6
6
  def call
7
7
  puts 'copying all service ActiveDocs'
8
8
 
9
- target_activedocs = source.list_activedocs.map do |source_activedoc|
9
+ target_activedocs = source.activedocs.map do |source_activedoc|
10
10
  source_activedoc.clone.tap do |target_activedoc|
11
11
  target_activedoc.delete('id')
12
12
  target_activedoc['service_id'] = target.id
@@ -4,15 +4,18 @@ module ThreeScaleToolbox
4
4
  include CopyTask
5
5
 
6
6
  def call
7
- source_methods = source.methods
8
- target_methods = target.methods
9
- target_hits_metric_id = target.hits['id']
10
- puts "original service hits metric #{source.hits['id']} has #{source_methods.size} methods"
11
- puts "target service hits metric #{target_hits_metric_id} has #{target_methods.size} methods"
7
+ source_hits_id = source.hits['id']
8
+ target_hits_id = target.hits['id']
9
+ source_methods = source.methods source_hits_id
10
+ target_methods = target.methods target_hits_id
11
+ puts "original service hits metric #{source_hits_id} has #{source_methods.size} methods"
12
+ puts "target service hits metric #{target_hits_id} has #{target_methods.size} methods"
12
13
  missing = missing_methods(source_methods, target_methods).each do |method|
13
- filtered_method = ThreeScaleToolbox::Helper.filter_params(%w[friendly_name system_name],
14
- method)
15
- target.create_method(target_hits_metric_id, filtered_method)
14
+ Entities::Method.create(
15
+ service: target,
16
+ parent_id: target_hits_id,
17
+ attrs: ThreeScaleToolbox::Helper.filter_params(%w[friendly_name system_name], method)
18
+ )
16
19
  end
17
20
  puts "created #{missing.size} missing methods on target service"
18
21
  end
@@ -14,7 +14,7 @@ module ThreeScaleToolbox
14
14
 
15
15
  missing.each do |metric|
16
16
  metric.delete('links')
17
- target.create_metric(metric)
17
+ Entities::Metric.create(service: target, attrs: metric)
18
18
  end
19
19
 
20
20
  puts "created #{missing.size} metrics on the target service"
@@ -4,7 +4,7 @@ module ThreeScaleToolbox
4
4
  include CopyTask
5
5
 
6
6
  def call
7
- target.update_proxy source.show_proxy
7
+ target.update_proxy source.proxy
8
8
  puts "updated proxy of #{target.id} to match the original"
9
9
  end
10
10
  end
@@ -9,7 +9,7 @@ module ThreeScaleToolbox
9
9
 
10
10
  def call
11
11
  puts 'deleting all target service ActiveDocs'
12
- target.list_activedocs.each do |activedoc|
12
+ target.activedocs.each do |activedoc|
13
13
  target.remote.delete_activedocs(activedoc['id'])
14
14
  end
15
15
  end
@@ -10,7 +10,7 @@ module ThreeScaleToolbox
10
10
  end
11
11
 
12
12
  def call
13
- source_obj = source.show_service
13
+ source_obj = source.attrs
14
14
  svc_obj = update_service target_service_params(source_obj)
15
15
  if (errors = svc_obj['errors'])
16
16
  raise ThreeScaleToolbox::Error, "Service has not been saved. Errors: #{errors}" \
@@ -22,7 +22,7 @@ module ThreeScaleToolbox
22
22
  private
23
23
 
24
24
  def update_service(service)
25
- svc_obj = target.update_service service
25
+ svc_obj = target.update service
26
26
 
27
27
  # Source and target remotes might not allow same set of deployment options
28
28
  # Invalid deployment option check
@@ -30,7 +30,7 @@ module ThreeScaleToolbox
30
30
  if (errors = svc_obj['errors']) &&
31
31
  ThreeScaleToolbox::Helper.service_invalid_deployment_option?(errors)
32
32
  service.delete('deployment_option')
33
- svc_obj = target.update_service(service)
33
+ svc_obj = target.update service
34
34
  end
35
35
 
36
36
  svc_obj
@@ -1,3 +1,3 @@
1
1
  module ThreeScaleToolbox
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0'
3
3
  end
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.9.0
4
+ version: 0.10.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: 2019-05-07 00:00:00.000000000 Z
12
+ date: 2019-05-14 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.3.0
90
+ version: 0.4.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.3.0
97
+ version: 0.4.0
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: cri
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -159,6 +159,16 @@ files:
159
159
  - lib/3scale_toolbox/commands/import_command/openapi/update_policies_step.rb
160
160
  - lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb
161
161
  - lib/3scale_toolbox/commands/import_command/openapi/update_service_proxy_step.rb
162
+ - lib/3scale_toolbox/commands/methods_command.rb
163
+ - lib/3scale_toolbox/commands/methods_command/apply_command.rb
164
+ - lib/3scale_toolbox/commands/methods_command/create_command.rb
165
+ - lib/3scale_toolbox/commands/methods_command/delete_command.rb
166
+ - lib/3scale_toolbox/commands/methods_command/list_command.rb
167
+ - lib/3scale_toolbox/commands/metrics_command.rb
168
+ - lib/3scale_toolbox/commands/metrics_command/apply_command.rb
169
+ - lib/3scale_toolbox/commands/metrics_command/create_command.rb
170
+ - lib/3scale_toolbox/commands/metrics_command/delete_command.rb
171
+ - lib/3scale_toolbox/commands/metrics_command/list_command.rb
162
172
  - lib/3scale_toolbox/commands/plans_command.rb
163
173
  - lib/3scale_toolbox/commands/plans_command/apply_command.rb
164
174
  - lib/3scale_toolbox/commands/plans_command/create_command.rb
@@ -191,6 +201,8 @@ files:
191
201
  - lib/3scale_toolbox/configuration.rb
192
202
  - lib/3scale_toolbox/entities.rb
193
203
  - lib/3scale_toolbox/entities/application_plan.rb
204
+ - lib/3scale_toolbox/entities/method.rb
205
+ - lib/3scale_toolbox/entities/metric.rb
194
206
  - lib/3scale_toolbox/entities/service.rb
195
207
  - lib/3scale_toolbox/error.rb
196
208
  - lib/3scale_toolbox/helper.rb