3scale_toolbox 0.19.3 → 1.0.0
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 +3 -2
- data/README.md +7 -6
- data/lib/3scale_toolbox/3scale_client_factory.rb +9 -7
- data/lib/3scale_toolbox/base_command.rb +5 -1
- data/lib/3scale_toolbox/cli/null_printer.rb +11 -0
- data/lib/3scale_toolbox/cli.rb +1 -0
- data/lib/3scale_toolbox/commands/3scale_command.rb +1 -0
- data/lib/3scale_toolbox/commands/activedocs_command/apply_command.rb +1 -1
- data/lib/3scale_toolbox/commands/activedocs_command/create_command.rb +8 -9
- data/lib/3scale_toolbox/commands/application_command/apply_command.rb +10 -2
- data/lib/3scale_toolbox/commands/import_command/openapi/create_activedocs_step.rb +1 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/create_backend_mapping_rule_step.rb +21 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/create_backend_method_step.rb +41 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/create_backend_step.rb +62 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/create_mapping_rule_step.rb +3 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/create_service_step.rb +7 -2
- data/lib/3scale_toolbox/commands/import_command/openapi/import_backend_step.rb +31 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/import_product_step.rb +30 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/method.rb +1 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/step.rb +27 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/update_policies_step.rb +1 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/update_service_oidc_conf_step.rb +2 -8
- data/lib/3scale_toolbox/commands/import_command/openapi/update_service_proxy_step.rb +4 -8
- data/lib/3scale_toolbox/commands/import_command/openapi.rb +44 -18
- data/lib/3scale_toolbox/commands/plans_command/import_command.rb +1 -1
- data/lib/3scale_toolbox/commands/policies_command/import_command.rb +1 -1
- data/lib/3scale_toolbox/commands/product_command/import_command.rb +1 -1
- data/lib/3scale_toolbox/commands/proxy_command/deploy_command.rb +54 -0
- data/lib/3scale_toolbox/commands/proxy_command/show_command.rb +54 -0
- data/lib/3scale_toolbox/commands/proxy_command/update_command.rb +75 -0
- data/lib/3scale_toolbox/commands/proxy_command.rb +28 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/deploy_command.rb +3 -2
- data/lib/3scale_toolbox/commands/service_command/show_command.rb +1 -2
- data/lib/3scale_toolbox/commands.rb +2 -2
- data/lib/3scale_toolbox/entities/backend.rb +13 -1
- data/lib/3scale_toolbox/entities/service.rb +1 -2
- data/lib/3scale_toolbox/openapi/oas3.rb +21 -7
- data/lib/3scale_toolbox/openapi/swagger.rb +21 -2
- data/lib/3scale_toolbox/resource_reader.rb +26 -11
- data/lib/3scale_toolbox/version.rb +1 -1
- data/licenses.xml +54 -64
- metadata +36 -10
- data/lib/3scale_toolbox/commands/update_command/service_command/copy_service_settings_task.rb +0 -35
- data/lib/3scale_toolbox/commands/update_command/service_command/delete_activedocs_task.rb +0 -24
- data/lib/3scale_toolbox/commands/update_command/service_command.rb +0 -80
- data/lib/3scale_toolbox/commands/update_command.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 769b120ad3d44861ec006d879fc2783201c8129b590ff4e54ca27d40725e30b7
|
4
|
+
data.tar.gz: 9097aeab4eb07152aeb47d997648c1c7dd1b49265cd233a8c36757cd2beb82c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62c74ff4d3bd4a76884fa5b907d3b36c22dccb3a938f200a2c90b7a209b06cd4cd10b7f11799aeef98b9f43fafb8c5e5e25d744a4fdb3f97408cde6be8f4df02
|
7
|
+
data.tar.gz: 5467a90b3ee4326b44f7b3acbd6baebc7ad50df2f279d7f824195910873e4bc906d230555536cea5eb5299e483f18613f248d27208e49ecad7795b7cbb115641
|
data/3scale_toolbox.gemspec
CHANGED
@@ -34,10 +34,11 @@ 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 = '>=
|
37
|
+
spec.required_ruby_version = '>= 3.0'
|
38
38
|
|
39
|
-
spec.add_dependency '3scale-api', '~> 1.
|
39
|
+
spec.add_dependency '3scale-api', '~> 1.6'
|
40
40
|
spec.add_dependency 'cri', '~> 2.15'
|
41
41
|
spec.add_dependency 'json-schema', '~> 2.8'
|
42
42
|
spec.add_dependency 'oas_parser', '~> 0.20'
|
43
|
+
spec.add_dependency 'activesupport', '>= 6', '< 8'
|
43
44
|
end
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
[![CircleCI](https://circleci.com/gh/3scale/3scale_toolbox.svg?style=svg)](https://circleci.com/gh/3scale/3scale_toolbox)
|
3
3
|
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
|
4
4
|
[![GitHub release](https://img.shields.io/github/v/release/3scale/3scale_toolbox.svg)](https://github.com/3scale/3scale_toolbox/releases/latest)
|
5
|
+
[![codecov](https://codecov.io/gh/3scale/3scale_toolbox/branch/main/graph/badge.svg?token=ojinl2NVv5)](https://codecov.io/gh/3scale/3scale_toolbox)
|
5
6
|
|
6
7
|
## Description
|
7
8
|
3scale toolbox is a set of tools to help you manage your 3scale product. Using the [3scale API Ruby Client](https://github.com/3scale/3scale-api-ruby).
|
@@ -22,7 +23,8 @@
|
|
22
23
|
* Create, Apply, List, Delete [Method](docs/method.md)
|
23
24
|
* Create, Apply, List, Show, Delete [Service](docs/service.md)
|
24
25
|
* Create, Apply, List, Delete [ActiveDocs](docs/activedocs.md)
|
25
|
-
*
|
26
|
+
* Show, Update, Deploy [APIcast proxy settings](docs/proxy.md)
|
27
|
+
* List, Show, Promote, Export [Staging/Production Proxy Configuration](docs/proxy-config.md)
|
26
28
|
* [Copy Policy Registry](docs/copy-policy-registry.md)
|
27
29
|
* Create, Apply, List, Show, Delete, Suspend, Resume [Applications](docs/applications.md)
|
28
30
|
* [Export/Import Product Policy Chain](docs/export-import-policy-chain.md)
|
@@ -39,8 +41,7 @@
|
|
39
41
|
## Requirements
|
40
42
|
Supported Ruby interpreters
|
41
43
|
|
42
|
-
* MRI
|
43
|
-
* MRI 2.7
|
44
|
+
* MRI 3.0
|
44
45
|
|
45
46
|
## Installation
|
46
47
|
Install the toolbox:
|
@@ -82,16 +83,18 @@ COMMANDS
|
|
82
83
|
import import super command
|
83
84
|
method method super command
|
84
85
|
metric metric super command
|
86
|
+
policies policies super command
|
85
87
|
policy-registry policy-registry super command
|
86
88
|
product product super command
|
89
|
+
proxy proxy super command
|
87
90
|
proxy-config proxy-config super command
|
88
91
|
remote remotes super command
|
89
92
|
service services super command
|
90
|
-
update [DEPRECATED] update super command
|
91
93
|
|
92
94
|
OPTIONS
|
93
95
|
-c --config-file=<value> 3scale toolbox configuration file (default:
|
94
96
|
$HOME/.3scalerc.yaml)
|
97
|
+
--disable-keep-alive Disable keep alive HTTP connection mode
|
95
98
|
-h --help show help for this command
|
96
99
|
-k --insecure Proceed and operate even for server
|
97
100
|
connections otherwise considered insecure
|
@@ -173,7 +176,6 @@ Then register the core command in `lib/3scale_toolbox/commands.rb`
|
|
173
176
|
+++ b/lib/3scale_toolbox/commands.rb
|
174
177
|
@@ -4,6 +4,7 @@ require '3scale_toolbox/commands/copy_command'
|
175
178
|
require '3scale_toolbox/commands/import_command'
|
176
|
-
require '3scale_toolbox/commands/update_command'
|
177
179
|
require '3scale_toolbox/commands/remote_command'
|
178
180
|
+require '3scale_toolbox/commands/service_list_command'
|
179
181
|
|
@@ -182,7 +184,6 @@ Then register the core command in `lib/3scale_toolbox/commands.rb`
|
|
182
184
|
@@ -12,7 +13,8 @@ module ThreeScaleToolbox
|
183
185
|
ThreeScaleToolbox::Commands::CopyCommand,
|
184
186
|
ThreeScaleToolbox::Commands::ImportCommand,
|
185
|
-
ThreeScaleToolbox::Commands::UpdateCommand,
|
186
187
|
- ThreeScaleToolbox::Commands::RemoteCommand::RemoteCommand
|
187
188
|
+ ThreeScaleToolbox::Commands::RemoteCommand::RemoteCommand,
|
188
189
|
+ ThreeScaleToolbox::Commands::ServiceListCommand
|
@@ -1,18 +1,19 @@
|
|
1
1
|
module ThreeScaleToolbox
|
2
2
|
class ThreeScaleClientFactory
|
3
3
|
class << self
|
4
|
-
def get(remotes, remote_str, verify_ssl, verbose = false)
|
5
|
-
new(remotes, remote_str, verify_ssl, verbose).call
|
4
|
+
def get(remotes, remote_str, verify_ssl, verbose = false, keep_alive = true)
|
5
|
+
new(remotes, remote_str, verify_ssl, verbose, keep_alive).call
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
attr_reader :remotes, :remote_str, :verify_ssl, :verbose
|
9
|
+
attr_reader :remotes, :remote_str, :verify_ssl, :verbose, :keep_alive
|
10
10
|
|
11
|
-
def initialize(remotes, remote_str, verify_ssl, verbose)
|
11
|
+
def initialize(remotes, remote_str, verify_ssl, verbose, keep_alive)
|
12
12
|
@remotes = remotes
|
13
13
|
@remote_str = remote_str
|
14
14
|
@verify_ssl = verify_ssl
|
15
15
|
@verbose = verbose
|
16
|
+
@keep_alive = keep_alive
|
16
17
|
end
|
17
18
|
|
18
19
|
def call
|
@@ -22,15 +23,16 @@ module ThreeScaleToolbox
|
|
22
23
|
remote = remotes.fetch(remote_str)
|
23
24
|
end
|
24
25
|
|
25
|
-
client = remote_client(**remote.merge(verify_ssl: verify_ssl))
|
26
|
+
client = remote_client(**remote.merge(verify_ssl: verify_ssl, keep_alive: keep_alive))
|
26
27
|
client = ProxyLogger.new(client) if verbose
|
27
28
|
RemoteCache.new(client)
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
31
32
|
|
32
|
-
def remote_client(endpoint:, authentication:, verify_ssl:)
|
33
|
-
ThreeScale::API.new(endpoint: endpoint, provider_key: authentication,
|
33
|
+
def remote_client(endpoint:, authentication:, verify_ssl:, keep_alive:)
|
34
|
+
ThreeScale::API.new(endpoint: endpoint, provider_key: authentication,
|
35
|
+
verify_ssl: verify_ssl, keep_alive: keep_alive)
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
@@ -46,7 +46,7 @@ module ThreeScaleToolbox
|
|
46
46
|
# Input param can be endpoint url or remote name
|
47
47
|
#
|
48
48
|
def threescale_client(str)
|
49
|
-
ThreeScaleClientFactory.get(remotes, str, verify_ssl, verbose)
|
49
|
+
ThreeScaleClientFactory.get(remotes, str, verify_ssl, verbose, keep_alive)
|
50
50
|
end
|
51
51
|
|
52
52
|
def verify_ssl
|
@@ -58,6 +58,10 @@ module ThreeScaleToolbox
|
|
58
58
|
options[:verbose]
|
59
59
|
end
|
60
60
|
|
61
|
+
def keep_alive
|
62
|
+
!options[:'disable-keep-alive']
|
63
|
+
end
|
64
|
+
|
61
65
|
def exit_with_message(message)
|
62
66
|
raise ThreeScaleToolbox::Error, message
|
63
67
|
end
|
data/lib/3scale_toolbox/cli.rb
CHANGED
@@ -17,6 +17,7 @@ module ThreeScaleToolbox
|
|
17
17
|
end
|
18
18
|
flag :k, :insecure, 'Proceed and operate even for server connections otherwise considered insecure'
|
19
19
|
flag nil, :verbose, 'Verbose mode'
|
20
|
+
flag nil, :'disable-keep-alive', 'Disable keep alive HTTP connection mode'
|
20
21
|
flag :h, :help, 'show help for this command' do |_, cmd|
|
21
22
|
puts cmd.help
|
22
23
|
exit 0
|
@@ -108,7 +108,7 @@ module ThreeScaleToolbox
|
|
108
108
|
|
109
109
|
def read_activedocs_json_spec
|
110
110
|
activedoc_spec = option_openapi_spec
|
111
|
-
activedoc_spec_content = load_resource(activedoc_spec)
|
111
|
+
activedoc_spec_content = load_resource(activedoc_spec, verify_ssl)
|
112
112
|
JSON.pretty_generate(activedoc_spec_content)
|
113
113
|
end
|
114
114
|
|
@@ -52,20 +52,19 @@ module ThreeScaleToolbox
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def activedocs_json_spec
|
55
|
-
|
56
|
-
activedoc_spec_content = load_resource(arguments[:activedocs_spec])
|
55
|
+
activedoc_spec_content = load_resource(arguments[:activedocs_spec], verify_ssl)
|
57
56
|
JSON.pretty_generate(activedoc_spec_content)
|
58
57
|
end
|
59
58
|
|
60
59
|
def activedocs_attrs
|
61
60
|
{
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
61
|
+
'service_id' => options[:'service-id'],
|
62
|
+
'published' => options[:'published'],
|
63
|
+
'skip_swagger_validations' => options[:'skip-swagger-validations'],
|
64
|
+
'description' => options[:'description'],
|
65
|
+
'system_name' => options[:'system-name'],
|
66
|
+
'name' => activedocs_name,
|
67
|
+
'body' => activedocs_json_spec,
|
69
68
|
}.compact
|
70
69
|
end
|
71
70
|
|
@@ -102,8 +102,8 @@ module ThreeScaleToolbox
|
|
102
102
|
{
|
103
103
|
'name' => option_name,
|
104
104
|
'description' => description,
|
105
|
-
'user_key' =>
|
106
|
-
'application_id' =>
|
105
|
+
'user_key' => user_key,
|
106
|
+
'application_id' => application_id,
|
107
107
|
'application_key' => option_app_key,
|
108
108
|
'redirect_url' => option_redirect_url,
|
109
109
|
}.compact
|
@@ -120,6 +120,14 @@ module ThreeScaleToolbox
|
|
120
120
|
}.compact
|
121
121
|
end
|
122
122
|
|
123
|
+
def user_key
|
124
|
+
application_ref if service.backend_version == '1'
|
125
|
+
end
|
126
|
+
|
127
|
+
def application_id
|
128
|
+
application_ref if service.backend_version == '2' || service.backend_version == 'oidc'
|
129
|
+
end
|
130
|
+
|
123
131
|
def account
|
124
132
|
@account ||= find_account
|
125
133
|
end
|
@@ -23,7 +23,7 @@ module ThreeScaleToolbox
|
|
23
23
|
unless ThreeScaleToolbox::Helper.system_name_already_taken_error? errors
|
24
24
|
|
25
25
|
# if activedocs system_name exists, ignore error, update activedocs
|
26
|
-
|
26
|
+
logger.info 'Activedocs exists, update!'
|
27
27
|
update_res = threescale_client.update_activedocs(find_activedocs_id, active_doc)
|
28
28
|
raise ThreeScaleToolbox::Error, "ActiveDocs has not been updated. #{update_res['errors']}" unless update_res['errors'].nil?
|
29
29
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ImportCommand
|
4
|
+
module OpenAPI
|
5
|
+
class CreateBackendMappingRulesStep
|
6
|
+
include Step
|
7
|
+
|
8
|
+
def call
|
9
|
+
backend.mapping_rules.each(&:delete)
|
10
|
+
|
11
|
+
report['mapping_rules'] = {}
|
12
|
+
operations.each do |op|
|
13
|
+
b_m_r = Entities::BackendMappingRule.create(backend: backend, attrs: op.mapping_rule)
|
14
|
+
report['mapping_rules'][op.friendly_name] = op.mapping_rule
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ImportCommand
|
4
|
+
module OpenAPI
|
5
|
+
class CreateBackendMethodsStep
|
6
|
+
include Step
|
7
|
+
|
8
|
+
def call
|
9
|
+
missing_operations.each do |op|
|
10
|
+
method = Entities::BackendMethod.create(backend: backend, attrs: op.method)
|
11
|
+
op.set(:metric_id, method.id)
|
12
|
+
end
|
13
|
+
|
14
|
+
existing_operations.each do |op|
|
15
|
+
method_attrs = methods_index.fetch(op.method['system_name']).attrs
|
16
|
+
method = Entities::BackendMethod.new(id: method_attrs.fetch('id'), backend: backend)
|
17
|
+
method.update(op.method)
|
18
|
+
op.set(:metric_id, method.id)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def methods_index
|
25
|
+
@methods_index ||= backend.methods.each_with_object({}) do |method, acc|
|
26
|
+
acc[method.system_name] = method
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def missing_operations
|
31
|
+
operations.reject { |op| methods_index.key? op.method['system_name'] }
|
32
|
+
end
|
33
|
+
|
34
|
+
def existing_operations
|
35
|
+
operations.select { |op| methods_index.key? op.method['system_name'] }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ImportCommand
|
4
|
+
module OpenAPI
|
5
|
+
class CreateBackendStep
|
6
|
+
include Step
|
7
|
+
|
8
|
+
##
|
9
|
+
# Creates backend with a given system_name
|
10
|
+
# If the backend already exists, update basic settings like name and description
|
11
|
+
def call
|
12
|
+
# Update backend and update context
|
13
|
+
self.backend = Entities::Backend.find_by_system_name(remote: threescale_client,
|
14
|
+
system_name: system_name)
|
15
|
+
if backend.nil?
|
16
|
+
# Create service and update context
|
17
|
+
self.backend = Entities::Backend.create(remote: threescale_client,
|
18
|
+
attrs: create_attrs)
|
19
|
+
else
|
20
|
+
backend.update(update_attrs)
|
21
|
+
end
|
22
|
+
|
23
|
+
report['id'] = backend.id
|
24
|
+
report['system_name'] = backend.system_name
|
25
|
+
report['private_endpoint'] = backend.private_endpoint
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def create_attrs
|
31
|
+
{
|
32
|
+
'name' => title,
|
33
|
+
'system_name' => system_name,
|
34
|
+
'description' => description,
|
35
|
+
'private_endpoint' => private_endpoint
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_attrs
|
40
|
+
{
|
41
|
+
'name' => title,
|
42
|
+
'description' => description,
|
43
|
+
'private_endpoint' => private_endpoint
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def system_name
|
48
|
+
target_system_name || title.downcase.gsub(/[^\w]/, '_')
|
49
|
+
end
|
50
|
+
|
51
|
+
def title
|
52
|
+
api_spec.title
|
53
|
+
end
|
54
|
+
|
55
|
+
def description
|
56
|
+
api_spec.description
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -6,10 +6,12 @@ module ThreeScaleToolbox
|
|
6
6
|
include Step
|
7
7
|
|
8
8
|
def call
|
9
|
+
report['mapping_rules'] = {}
|
9
10
|
operations.each do |op|
|
10
11
|
Entities::MappingRule.create(service: service,
|
11
12
|
attrs: op.mapping_rule)
|
12
|
-
|
13
|
+
logger.info "Created #{op.http_method} #{op.pattern} endpoint"
|
14
|
+
report['mapping_rules'][op.friendly_name] = op.mapping_rule
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -16,11 +16,16 @@ module ThreeScaleToolbox
|
|
16
16
|
# Create service and update context
|
17
17
|
self.service = Entities::Service.create(remote: threescale_client,
|
18
18
|
service_params: service_settings)
|
19
|
-
|
19
|
+
logger.info "Created service id: #{service.id}, name: #{service_name}"
|
20
20
|
else
|
21
21
|
service.update(service_settings)
|
22
|
-
|
22
|
+
logger.info "Updated service id: #{service.id}, name: #{service_name}"
|
23
23
|
end
|
24
|
+
|
25
|
+
report['id'] = service.id
|
26
|
+
report['system_name'] = service.system_name
|
27
|
+
report['name'] = service.name
|
28
|
+
report['backend_version'] = api_spec.service_backend_version
|
24
29
|
end
|
25
30
|
|
26
31
|
private
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ImportCommand
|
4
|
+
module OpenAPI
|
5
|
+
class ImportBackendStep
|
6
|
+
include Step
|
7
|
+
|
8
|
+
def call
|
9
|
+
verify_params
|
10
|
+
|
11
|
+
tasks = []
|
12
|
+
tasks << CreateBackendStep.new(context)
|
13
|
+
tasks << CreateBackendMethodsStep.new(context)
|
14
|
+
tasks << CreateBackendMappingRulesStep.new(context)
|
15
|
+
|
16
|
+
# run tasks
|
17
|
+
tasks.each(&:call)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def verify_params
|
23
|
+
if private_endpoint.nil?
|
24
|
+
raise ThreeScaleToolbox::Error, 'private endpoint not specified'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ImportCommand
|
4
|
+
module OpenAPI
|
5
|
+
class ImportProductStep
|
6
|
+
include Step
|
7
|
+
|
8
|
+
def call
|
9
|
+
tasks = []
|
10
|
+
tasks << CreateServiceStep.new(context)
|
11
|
+
# other tasks might read proxy settings (CreateActiveDocsStep does)
|
12
|
+
tasks << UpdateServiceProxyStep.new(context)
|
13
|
+
tasks << CreateMethodsStep.new(context)
|
14
|
+
tasks << ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::DestroyMappingRulesTask.new(context)
|
15
|
+
tasks << CreateMappingRulesStep.new(context)
|
16
|
+
tasks << CreateActiveDocsStep.new(context)
|
17
|
+
tasks << UpdateServiceOidcConfStep.new(context)
|
18
|
+
tasks << UpdatePoliciesStep.new(context)
|
19
|
+
|
20
|
+
# run tasks
|
21
|
+
tasks.each(&:call)
|
22
|
+
|
23
|
+
# This should be the last step
|
24
|
+
ThreeScaleToolbox::Commands::ServiceCommand::CopyCommand::BumpProxyVersionTask.new(service: context[:target]).call
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -9,6 +9,18 @@ module ThreeScaleToolbox
|
|
9
9
|
@context = context
|
10
10
|
end
|
11
11
|
|
12
|
+
def report
|
13
|
+
context[:report] ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def backend
|
17
|
+
context[:backend_target]
|
18
|
+
end
|
19
|
+
|
20
|
+
def backend=(backend_obj)
|
21
|
+
context[:backend_target] = backend_obj
|
22
|
+
end
|
23
|
+
|
12
24
|
# Can be nil on initialization time and not nil afterwards
|
13
25
|
# method to fetch from context required
|
14
26
|
def service
|
@@ -41,7 +53,7 @@ module ThreeScaleToolbox
|
|
41
53
|
public_base_path: public_base_path,
|
42
54
|
path: op[:path],
|
43
55
|
verb: op[:verb],
|
44
|
-
|
56
|
+
operation_id: op[:operation_id],
|
45
57
|
description: op[:description],
|
46
58
|
prefix_matching: prefix_matching,
|
47
59
|
)
|
@@ -101,6 +113,16 @@ module ThreeScaleToolbox
|
|
101
113
|
context[:prefix_matching]
|
102
114
|
end
|
103
115
|
|
116
|
+
def private_endpoint
|
117
|
+
override_private_base_url || host
|
118
|
+
end
|
119
|
+
|
120
|
+
def host
|
121
|
+
return if api_spec.host.nil?
|
122
|
+
|
123
|
+
"#{api_spec.scheme || 'https'}://#{api_spec.host}"
|
124
|
+
end
|
125
|
+
|
104
126
|
def base_path
|
105
127
|
api_spec.base_path || '/'
|
106
128
|
end
|
@@ -112,6 +134,10 @@ module ThreeScaleToolbox
|
|
112
134
|
def private_base_path
|
113
135
|
override_private_basepath || base_path
|
114
136
|
end
|
137
|
+
|
138
|
+
def logger
|
139
|
+
context[:logger]
|
140
|
+
end
|
115
141
|
end
|
116
142
|
end
|
117
143
|
end
|
@@ -20,7 +20,7 @@ module ThreeScaleToolbox
|
|
20
20
|
raise ThreeScaleToolbox::Error, "Service oidc has not been updated. #{errors}"
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
logger.info 'Service oidc updated'
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
@@ -29,13 +29,7 @@ module ThreeScaleToolbox
|
|
29
29
|
# only applies to oauth2 sec type
|
30
30
|
return if api_spec.security.nil? || api_spec.security[:type] != 'oauth2'
|
31
31
|
|
32
|
-
|
33
|
-
standard_flow_enabled: false,
|
34
|
-
implicit_flow_enabled: false,
|
35
|
-
service_accounts_enabled: false,
|
36
|
-
direct_access_grants_enabled: false
|
37
|
-
}.merge(api_spec.security[:flow] => true)
|
38
|
-
settings.merge!(oidc_configuration)
|
32
|
+
settings.merge!(api_spec.security[:flows] || {})
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
@@ -22,7 +22,7 @@ module ThreeScaleToolbox
|
|
22
22
|
raise ThreeScaleToolbox::Error, "Service proxy has not been updated. #{errors}"
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
logger.info 'Service proxy updated'
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -31,12 +31,14 @@ module ThreeScaleToolbox
|
|
31
31
|
return if production_public_base_url.nil?
|
32
32
|
|
33
33
|
settings[:endpoint] = production_public_base_url
|
34
|
+
report['endpoint'] = production_public_base_url
|
34
35
|
end
|
35
36
|
|
36
37
|
def add_sandbox_endpoint_settings(settings)
|
37
38
|
return if staging_public_base_url.nil?
|
38
39
|
|
39
40
|
settings[:sandbox_endpoint] = staging_public_base_url
|
41
|
+
report['sandbox_endpoint'] = staging_public_base_url
|
40
42
|
end
|
41
43
|
|
42
44
|
def add_api_backend_settings(settings)
|
@@ -74,13 +76,7 @@ module ThreeScaleToolbox
|
|
74
76
|
end
|
75
77
|
|
76
78
|
def private_base_url
|
77
|
-
override_private_base_url ||
|
78
|
-
end
|
79
|
-
|
80
|
-
def private_base_url_from_openapi
|
81
|
-
return if api_spec.host.nil?
|
82
|
-
|
83
|
-
"#{api_spec.scheme || 'https'}://#{api_spec.host}"
|
79
|
+
override_private_base_url || host
|
84
80
|
end
|
85
81
|
end
|
86
82
|
end
|