3scale_toolbox 0.18.2 → 0.19.2
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 +3 -3
- data/README.md +1 -2
- data/lib/3scale_toolbox/commands/backend_command/copy_command/delete_mapping_rules_task.rb +18 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command/task.rb +4 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command.rb +4 -1
- data/lib/3scale_toolbox/commands/import_command/import_csv.rb +8 -8
- data/lib/3scale_toolbox/commands/import_command/openapi/create_activedocs_step.rb +4 -3
- data/lib/3scale_toolbox/commands/import_command/openapi.rb +2 -0
- data/lib/3scale_toolbox/commands/product_command/copy_command/copy_backends_task.rb +6 -0
- data/lib/3scale_toolbox/commands/product_command/copy_command.rb +3 -2
- data/lib/3scale_toolbox/commands/product_command/import_command.rb +1 -0
- data/lib/3scale_toolbox/proxy_logger.rb +2 -0
- data/lib/3scale_toolbox/remote_cache.rb +7 -1
- data/lib/3scale_toolbox/version.rb +1 -1
- data/licenses.xml +14 -24
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dee95ebde6b993418261f63857e80e18c8dd94bcfea9b92c6fa505cbbfdade99
|
4
|
+
data.tar.gz: ff8c3c97adb47ad141b2af12f8d4481330f9f25ce8819ecb5162666c6eedc521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41473b4f397a15743224e1848aecdd21abdf8a0246833522c2a3aadf6ed5c5cc58970e4761bb61801afa2e32b4326a33d15bf71db3f926c06a7620f7daa5e8b1
|
7
|
+
data.tar.gz: 6d1396f584b308ba1f978f02981605023d346c2ff39d806e1e3b265b7d16233f72beb4f7fc896e99a6d62d5b765878d5e9c71ee4eeb444db91101decc0a16bae
|
data/3scale_toolbox.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = '3scale_toolbox'
|
9
9
|
spec.version = ThreeScaleToolbox::VERSION
|
10
10
|
spec.licenses = ['MIT']
|
11
|
-
spec.authors = ['
|
12
|
-
spec.email = ['
|
11
|
+
spec.authors = ['Miguel Soriano', 'Eguzki Astiz Lezaun']
|
12
|
+
spec.email = ['msoriano@redhat.com', 'eastizle@redhat.com']
|
13
13
|
|
14
14
|
spec.summary = %q{3scale Toolbox.}
|
15
15
|
spec.description = %q{3scale tools to manage your API from the terminal.}
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'rake', '~> 13.0'
|
35
35
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
36
36
|
spec.add_development_dependency 'webmock', '~> 3.4'
|
37
|
-
spec.required_ruby_version = '>= 2.
|
37
|
+
spec.required_ruby_version = '>= 2.6'
|
38
38
|
|
39
39
|
spec.add_dependency '3scale-api', '~> 1.4'
|
40
40
|
spec.add_dependency 'cri', '~> 2.15'
|
data/README.md
CHANGED
@@ -39,7 +39,6 @@
|
|
39
39
|
## Requirements
|
40
40
|
Supported Ruby interpreters
|
41
41
|
|
42
|
-
* MRI 2.5
|
43
42
|
* MRI 2.6
|
44
43
|
* MRI 2.7
|
45
44
|
|
@@ -219,5 +218,5 @@ Install, uninstall and update plugins using tools like [RubyGems](https://guides
|
|
219
218
|
|
220
219
|
## Contributing
|
221
220
|
|
222
|
-
|
221
|
+
If you are interested in contributing to 3scale Toolbox, please refer to instructions available [here](docs/contributing.md)
|
223
222
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module BackendCommand
|
4
|
+
module CopyCommand
|
5
|
+
class DeleteMappingRulesTask
|
6
|
+
include Task
|
7
|
+
|
8
|
+
# entrypoint
|
9
|
+
def run
|
10
|
+
return unless delete_mapping_rules
|
11
|
+
|
12
|
+
target_backend.mapping_rules.each(&:delete)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -2,6 +2,7 @@ require '3scale_toolbox/commands/backend_command/copy_command/task'
|
|
2
2
|
require '3scale_toolbox/commands/backend_command/copy_command/create_or_update_target_backend_task'
|
3
3
|
require '3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task'
|
4
4
|
require '3scale_toolbox/commands/backend_command/copy_command/copy_methods_task'
|
5
|
+
require '3scale_toolbox/commands/backend_command/copy_command/delete_mapping_rules_task'
|
5
6
|
require '3scale_toolbox/commands/backend_command/copy_command/copy_mapping_rules_task'
|
6
7
|
|
7
8
|
module ThreeScaleToolbox
|
@@ -17,7 +18,7 @@ module ThreeScaleToolbox
|
|
17
18
|
summary 'Copy backend'
|
18
19
|
description <<-HEREDOC
|
19
20
|
This command makes a copy of the referenced backend.
|
20
|
-
Target backend will be searched by source backend system name. System name can be
|
21
|
+
Target backend will be searched by the source backend system name. System name can be overridden with `--target-system-name` option.
|
21
22
|
If a backend with the selected `system-name` is not found, it will be created.
|
22
23
|
\n Components of the backend being copied:
|
23
24
|
\nmetrics
|
@@ -41,6 +42,7 @@ module ThreeScaleToolbox
|
|
41
42
|
# First metrics as methods need 'hits' metric in target backend
|
42
43
|
tasks << CopyCommand::CopyMetricsTask.new(context)
|
43
44
|
tasks << CopyCommand::CopyMethodsTask.new(context)
|
45
|
+
tasks << CopyCommand::DeleteMappingRulesTask.new(context)
|
44
46
|
tasks << CopyCommand::CopyMappingRulesTask.new(context)
|
45
47
|
tasks.each(&:call)
|
46
48
|
end
|
@@ -56,6 +58,7 @@ module ThreeScaleToolbox
|
|
56
58
|
source_remote: threescale_client(fetch_required_option(:source)),
|
57
59
|
target_remote: threescale_client(fetch_required_option(:destination)),
|
58
60
|
source_backend_ref: arguments[:source_backend],
|
61
|
+
delete_mapping_rules: true,
|
59
62
|
option_target_system_name: options[:'target-system-name']
|
60
63
|
}
|
61
64
|
end
|
@@ -104,14 +104,14 @@ module ThreeScaleToolbox
|
|
104
104
|
|
105
105
|
# create a mapping rule
|
106
106
|
if (metric_id = metric['id'] || method['id'])
|
107
|
-
mapping_rule = client.create_mapping_rule(service['id'],
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
107
|
+
mapping_rule = client.create_mapping_rule(service['id'],{
|
108
|
+
metric_id: metric_id,
|
109
|
+
pattern: item['endpoint_path'],
|
110
|
+
http_method: item['endpoint_http_method'],
|
111
|
+
metric_system_name: item['endpoint_system_name'],
|
112
|
+
auth_app_key: auth_app_key_according_service(service),
|
113
|
+
delta: 1
|
114
|
+
})
|
115
115
|
|
116
116
|
if mapping_rule['errors'].nil?
|
117
117
|
stats[:mapping_rules] += 1
|
@@ -53,9 +53,10 @@ module ThreeScaleToolbox
|
|
53
53
|
# Other processing steps can work with original openapi spec
|
54
54
|
Helper.hash_deep_dup(resource).tap do |activedocs|
|
55
55
|
# public production base URL
|
56
|
-
# the basePath field is updated to a new value only when
|
57
|
-
|
58
|
-
|
56
|
+
# the basePath field is updated to a new value only when overridden by optional param
|
57
|
+
unless service.proxy['endpoint'].nil?
|
58
|
+
api_spec.set_server_url(activedocs, URI.join(service.proxy.fetch('endpoint'), public_base_path))
|
59
|
+
end
|
59
60
|
# security definitions
|
60
61
|
# just valid for oauth2 when oidc_issuer_endpoint is supplied
|
61
62
|
if !api_spec.security.nil? && api_spec.security[:type] == 'oauth2' && !oidc_issuer_endpoint.nil?
|
@@ -108,6 +108,8 @@ module ThreeScaleToolbox
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def openapi_parser
|
111
|
+
raise ThreeScaleToolbox::Error, 'only JSON/YAML format is supported' unless openapi_resource.is_a?(Hash)
|
112
|
+
|
111
113
|
if openapi_resource.key?('openapi')
|
112
114
|
ThreeScaleToolbox::OpenAPI::OAS3.build(openapi_path, openapi_resource, validate: validate)
|
113
115
|
else
|
@@ -27,6 +27,7 @@ module ThreeScaleToolbox
|
|
27
27
|
# First metrics as methods need 'hits' metric in target backend
|
28
28
|
tasks << Commands::BackendCommand::CopyCommand::CopyMetricsTask.new(backend_context)
|
29
29
|
tasks << Commands::BackendCommand::CopyCommand::CopyMethodsTask.new(backend_context)
|
30
|
+
tasks << Commands::BackendCommand::CopyCommand::DeleteMappingRulesTask.new(backend_context)
|
30
31
|
tasks << Commands::BackendCommand::CopyCommand::CopyMappingRulesTask.new(backend_context)
|
31
32
|
tasks.each(&:call)
|
32
33
|
|
@@ -72,12 +73,17 @@ module ThreeScaleToolbox
|
|
72
73
|
context.fetch(:logger)
|
73
74
|
end
|
74
75
|
|
76
|
+
def delete_mapping_rules
|
77
|
+
context.fetch(:delete_mapping_rules, false)
|
78
|
+
end
|
79
|
+
|
75
80
|
def create_backend_context(source_backend)
|
76
81
|
{
|
77
82
|
source_remote: source_remote,
|
78
83
|
target_remote: target_remote,
|
79
84
|
source_backend: source_backend,
|
80
85
|
source_backend_ref: source_backend.id,
|
86
|
+
delete_mapping_rules: delete_mapping_rules,
|
81
87
|
logger: logger
|
82
88
|
}
|
83
89
|
end
|
@@ -14,13 +14,13 @@ module ThreeScaleToolbox
|
|
14
14
|
summary 'Copy product'
|
15
15
|
description <<-HEREDOC
|
16
16
|
This command makes a copy of the referenced product.
|
17
|
-
Target product will be searched by source product system name. System name can be
|
17
|
+
Target product will be searched by the source product system name. System name can be overridden with `--target-system-name` option.
|
18
18
|
If a product with the selected `system_name` is not found, it will be created.
|
19
19
|
\n Components of the product being copied:
|
20
20
|
\nproduct configuration
|
21
21
|
\nproduct settings
|
22
22
|
\nproduct methods&metrics: Only missing metrics&methods will be created.
|
23
|
-
\nproduct mapping rules:
|
23
|
+
\nproduct mapping rules: mapping rules will be replaced. Existing mapping rules will be removed.
|
24
24
|
\nproduct application plans & pricing rules & limits: Only missing application plans & pricing rules & limits will be created.
|
25
25
|
\nproduct application usage rules
|
26
26
|
\nproduct policies
|
@@ -73,6 +73,7 @@ module ThreeScaleToolbox
|
|
73
73
|
source_remote: threescale_client(fetch_required_option(:source)),
|
74
74
|
target_remote: threescale_client(fetch_required_option(:destination)),
|
75
75
|
source_service_ref: arguments[:source_product],
|
76
|
+
delete_mapping_rules: true,
|
76
77
|
option_target_system_name: options[:'target-system-name']
|
77
78
|
}
|
78
79
|
end
|
@@ -5,6 +5,7 @@ module ThreeScaleToolbox
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def method_missing(name, *args)
|
8
|
+
# Correct delegation https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html
|
8
9
|
start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
|
9
10
|
result = @subject.public_send(name, *args)
|
10
11
|
ensure
|
@@ -12,6 +13,7 @@ module ThreeScaleToolbox
|
|
12
13
|
::Kernel.warn "-- call #{name} args |#{args.inspect[0..2000]}| response |#{result.inspect[0..2000]}| - (#{end_time}s)"
|
13
14
|
result
|
14
15
|
end
|
16
|
+
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
|
15
17
|
|
16
18
|
def public_send(name, *args)
|
17
19
|
method_missing(name, *args)
|
@@ -141,7 +141,13 @@ module ThreeScaleToolbox
|
|
141
141
|
###
|
142
142
|
|
143
143
|
def method_missing(name, *args)
|
144
|
-
|
144
|
+
# Correct delegation https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html
|
145
|
+
@subject.public_send(name, *args)
|
146
|
+
end
|
147
|
+
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
|
148
|
+
|
149
|
+
def public_send(name, *args)
|
150
|
+
method_missing(name, *args)
|
145
151
|
end
|
146
152
|
|
147
153
|
def respond_to_missing?(method_name, include_private = false)
|
data/licenses.xml
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
</dependency>
|
14
14
|
<dependency>
|
15
15
|
<packageName>3scale_toolbox</packageName>
|
16
|
-
<version>0.
|
16
|
+
<version>0.19.2</version>
|
17
17
|
<licenses>
|
18
18
|
<license>
|
19
19
|
<name>MIT</name>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
</dependency>
|
24
24
|
<dependency>
|
25
25
|
<packageName>activesupport</packageName>
|
26
|
-
<version>6.1.
|
26
|
+
<version>6.1.4.1</version>
|
27
27
|
<licenses>
|
28
28
|
<license>
|
29
29
|
<name>MIT</name>
|
@@ -33,7 +33,7 @@
|
|
33
33
|
</dependency>
|
34
34
|
<dependency>
|
35
35
|
<packageName>addressable</packageName>
|
36
|
-
<version>2.
|
36
|
+
<version>2.8.0</version>
|
37
37
|
<licenses>
|
38
38
|
<license>
|
39
39
|
<name>Apache 2.0</name>
|
@@ -53,7 +53,7 @@
|
|
53
53
|
</dependency>
|
54
54
|
<dependency>
|
55
55
|
<packageName>bundler</packageName>
|
56
|
-
<version>2.
|
56
|
+
<version>2.2.21</version>
|
57
57
|
<licenses>
|
58
58
|
<license>
|
59
59
|
<name>MIT</name>
|
@@ -63,7 +63,7 @@
|
|
63
63
|
</dependency>
|
64
64
|
<dependency>
|
65
65
|
<packageName>codecov</packageName>
|
66
|
-
<version>0.5.
|
66
|
+
<version>0.5.2</version>
|
67
67
|
<licenses>
|
68
68
|
<license>
|
69
69
|
<name>MIT</name>
|
@@ -83,7 +83,7 @@
|
|
83
83
|
</dependency>
|
84
84
|
<dependency>
|
85
85
|
<packageName>concurrent-ruby</packageName>
|
86
|
-
<version>1.1.
|
86
|
+
<version>1.1.9</version>
|
87
87
|
<licenses>
|
88
88
|
<license>
|
89
89
|
<name>MIT</name>
|
@@ -141,7 +141,7 @@
|
|
141
141
|
</dependency>
|
142
142
|
<dependency>
|
143
143
|
<packageName>docile</packageName>
|
144
|
-
<version>1.
|
144
|
+
<version>1.4.0</version>
|
145
145
|
<licenses>
|
146
146
|
<license>
|
147
147
|
<name>MIT</name>
|
@@ -228,16 +228,6 @@
|
|
228
228
|
<url>http://opensource.org/licenses/mit-license</url>
|
229
229
|
</license>
|
230
230
|
</licenses>
|
231
|
-
</dependency>
|
232
|
-
<dependency>
|
233
|
-
<packageName>mini_portile2</packageName>
|
234
|
-
<version>2.5.1</version>
|
235
|
-
<licenses>
|
236
|
-
<license>
|
237
|
-
<name>MIT</name>
|
238
|
-
<url>http://opensource.org/licenses/mit-license</url>
|
239
|
-
</license>
|
240
|
-
</licenses>
|
241
231
|
</dependency>
|
242
232
|
<dependency>
|
243
233
|
<packageName>minitest</packageName>
|
@@ -271,7 +261,7 @@
|
|
271
261
|
</dependency>
|
272
262
|
<dependency>
|
273
263
|
<packageName>nokogiri</packageName>
|
274
|
-
<version>1.
|
264
|
+
<version>1.12.4</version>
|
275
265
|
<licenses>
|
276
266
|
<license>
|
277
267
|
<name>MIT</name>
|
@@ -301,7 +291,7 @@
|
|
301
291
|
</dependency>
|
302
292
|
<dependency>
|
303
293
|
<packageName>pry</packageName>
|
304
|
-
<version>0.
|
294
|
+
<version>0.14.1</version>
|
305
295
|
<licenses>
|
306
296
|
<license>
|
307
297
|
<name>MIT</name>
|
@@ -385,7 +375,7 @@
|
|
385
375
|
</dependency>
|
386
376
|
<dependency>
|
387
377
|
<packageName>rspec-mocks</packageName>
|
388
|
-
<version>3.10.
|
378
|
+
<version>3.10.2</version>
|
389
379
|
<licenses>
|
390
380
|
<license>
|
391
381
|
<name>MIT</name>
|
@@ -395,7 +385,7 @@
|
|
395
385
|
</dependency>
|
396
386
|
<dependency>
|
397
387
|
<packageName>rspec-support</packageName>
|
398
|
-
<version>3.10.
|
388
|
+
<version>3.10.2</version>
|
399
389
|
<licenses>
|
400
390
|
<license>
|
401
391
|
<name>MIT</name>
|
@@ -405,7 +395,7 @@
|
|
405
395
|
</dependency>
|
406
396
|
<dependency>
|
407
397
|
<packageName>ruby2_keywords</packageName>
|
408
|
-
<version>0.0.
|
398
|
+
<version>0.0.5</version>
|
409
399
|
<licenses>
|
410
400
|
<license>
|
411
401
|
<name>ruby</name>
|
@@ -449,7 +439,7 @@
|
|
449
439
|
</dependency>
|
450
440
|
<dependency>
|
451
441
|
<packageName>simplecov_json_formatter</packageName>
|
452
|
-
<version>0.1.
|
442
|
+
<version>0.1.3</version>
|
453
443
|
<licenses>
|
454
444
|
<license>
|
455
445
|
<name>MIT</name>
|
@@ -489,7 +479,7 @@
|
|
489
479
|
</dependency>
|
490
480
|
<dependency>
|
491
481
|
<packageName>webmock</packageName>
|
492
|
-
<version>3.
|
482
|
+
<version>3.13.0</version>
|
493
483
|
<licenses>
|
494
484
|
<license>
|
495
485
|
<name>MIT</name>
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 3scale_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Miguel Soriano
|
8
8
|
- Eguzki Astiz Lezaun
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-09-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -139,7 +139,7 @@ dependencies:
|
|
139
139
|
version: '0.20'
|
140
140
|
description: 3scale tools to manage your API from the terminal.
|
141
141
|
email:
|
142
|
-
-
|
142
|
+
- msoriano@redhat.com
|
143
143
|
- eastizle@redhat.com
|
144
144
|
executables:
|
145
145
|
- 3scale
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/3scale_toolbox/commands/backend_command/copy_command/copy_methods_task.rb
|
185
185
|
- lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb
|
186
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/delete_mapping_rules_task.rb
|
187
188
|
- lib/3scale_toolbox/commands/backend_command/copy_command/task.rb
|
188
189
|
- lib/3scale_toolbox/commands/copy_command.rb
|
189
190
|
- lib/3scale_toolbox/commands/copy_command/service_command.rb
|
@@ -343,14 +344,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
343
344
|
requirements:
|
344
345
|
- - ">="
|
345
346
|
- !ruby/object:Gem::Version
|
346
|
-
version: '2.
|
347
|
+
version: '2.6'
|
347
348
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
348
349
|
requirements:
|
349
350
|
- - ">="
|
350
351
|
- !ruby/object:Gem::Version
|
351
352
|
version: '0'
|
352
353
|
requirements: []
|
353
|
-
rubygems_version: 3.
|
354
|
+
rubygems_version: 3.0.3
|
354
355
|
signing_key:
|
355
356
|
specification_version: 4
|
356
357
|
summary: 3scale Toolbox.
|