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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77ce2f220c416d634541773317d35da8018a75d7e3d91c009338b7a971614eee
|
|
4
|
+
data.tar.gz: 4d5ee60b4cc55c0ba002fc007ba578801012c9c5580b4fe540f03c3c9dbb2d26
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 947d84f88a8b8e673ea313ba79a3e72eda4b03b85af30f12003b8c6b867f98addf8bc0eebea2e4a3c3bdbc64f80f241346c0e70bdb2ec9e5e9b3a698ab539438
|
|
7
|
+
data.tar.gz: 106e99be0a64a27284d6b7a64b796ac0ef6b14e30011b3d42366d1e6494e9f623fdb6221924204830e4e9dbb59a6086b0aac8601a4e7b5a968a59f9bfaefed61
|
data/3scale_toolbox.gemspec
CHANGED
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
|
36
36
|
spec.add_development_dependency 'webmock', '~> 3.4'
|
|
37
37
|
spec.required_ruby_version = '>= 2.5'
|
|
38
38
|
|
|
39
|
-
spec.add_dependency '3scale-api', '~>
|
|
39
|
+
spec.add_dependency '3scale-api', '~> 1.0'
|
|
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'
|
data/README.md
CHANGED
|
@@ -12,7 +12,9 @@ See the LICENSE and NOTICE files that should have been provided along with this
|
|
|
12
12
|
* [Requirements](#requirements)
|
|
13
13
|
* [Installation](#installation)
|
|
14
14
|
* [Usage](#usage)
|
|
15
|
-
* [Copy
|
|
15
|
+
* [Copy service](docs/copy-service.md)
|
|
16
|
+
* [Copy backend](docs/copy-backend.md)
|
|
17
|
+
* [Copy product](docs/copy-product.md)
|
|
16
18
|
* [Import from CSV](docs/import-csv.md)
|
|
17
19
|
* [Import from OpenAPI definition](docs/openapi.md)
|
|
18
20
|
* [Export/Import Application Plan](docs/export-import-app-plan.md)
|
|
@@ -73,6 +75,7 @@ COMMANDS
|
|
|
73
75
|
activedocs activedocs super command
|
|
74
76
|
application application super command
|
|
75
77
|
application-plan application-plan super command
|
|
78
|
+
backend backend super command
|
|
76
79
|
copy copy super command
|
|
77
80
|
help show help
|
|
78
81
|
import import super command
|
data/lib/3scale_toolbox.rb
CHANGED
|
@@ -20,7 +20,6 @@ require '3scale_toolbox/configuration'
|
|
|
20
20
|
require '3scale_toolbox/remotes'
|
|
21
21
|
require '3scale_toolbox/3scale_client_factory'
|
|
22
22
|
require '3scale_toolbox/entities'
|
|
23
|
-
require '3scale_toolbox/tasks'
|
|
24
23
|
require '3scale_toolbox/attribute_filters'
|
|
25
24
|
require '3scale_toolbox/base_command'
|
|
26
25
|
require '3scale_toolbox/openapi'
|
data/lib/3scale_toolbox/cli.rb
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
require '3scale_toolbox/cli/error_handler'
|
|
2
|
+
require '3scale_toolbox/cli/json_printer'
|
|
3
|
+
require '3scale_toolbox/cli/yaml_printer'
|
|
4
|
+
require '3scale_toolbox/cli/custom_table_printer'
|
|
5
|
+
require '3scale_toolbox/cli/output_flag'
|
|
2
6
|
|
|
3
7
|
module ThreeScaleToolbox::CLI
|
|
4
8
|
def self.root_command
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module ThreeScaleToolbox
|
|
2
|
+
module CLI
|
|
3
|
+
class CustomTablePrinter
|
|
4
|
+
attr_reader :fields
|
|
5
|
+
|
|
6
|
+
def initialize(fields)
|
|
7
|
+
@fields = fields
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def print_record(record)
|
|
11
|
+
print_collection([record])
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def print_collection(collection)
|
|
15
|
+
print_header
|
|
16
|
+
print_data(collection)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def print_header
|
|
22
|
+
puts fields.map(&:upcase).join("\t")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def print_data(collection)
|
|
26
|
+
collection.each do |obj|
|
|
27
|
+
puts fields.map { |field| obj.fetch(field, '(empty)').to_s }.join("\t")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module ThreeScaleToolbox
|
|
2
|
+
module CLI
|
|
3
|
+
class PrinterTransformer
|
|
4
|
+
def call(output_format)
|
|
5
|
+
raise unless %w[yaml json].include?(output_format)
|
|
6
|
+
|
|
7
|
+
case output_format
|
|
8
|
+
when 'yaml'
|
|
9
|
+
YamlPrinter.new
|
|
10
|
+
when 'json'
|
|
11
|
+
JsonPrinter.new
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.output_flag(dsl)
|
|
17
|
+
dsl.option :o, :output, 'Output format. One of: json|yaml', argument: :required, transform: PrinterTransformer.new
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require '3scale_toolbox/commands/3scale_command'
|
|
2
2
|
require '3scale_toolbox/commands/help_command'
|
|
3
|
-
require '3scale_toolbox/commands/copy_command'
|
|
4
3
|
require '3scale_toolbox/commands/import_command'
|
|
5
4
|
require '3scale_toolbox/commands/update_command'
|
|
6
5
|
require '3scale_toolbox/commands/remote_command'
|
|
@@ -8,11 +7,14 @@ require '3scale_toolbox/commands/plans_command'
|
|
|
8
7
|
require '3scale_toolbox/commands/metrics_command'
|
|
9
8
|
require '3scale_toolbox/commands/methods_command'
|
|
10
9
|
require '3scale_toolbox/commands/service_command'
|
|
10
|
+
require '3scale_toolbox/commands/copy_command'
|
|
11
11
|
require '3scale_toolbox/commands/activedocs_command'
|
|
12
12
|
require '3scale_toolbox/commands/account_command'
|
|
13
13
|
require '3scale_toolbox/commands/proxy_config_command'
|
|
14
14
|
require '3scale_toolbox/commands/policy_registry_command'
|
|
15
15
|
require '3scale_toolbox/commands/application_command'
|
|
16
|
+
require '3scale_toolbox/commands/backend_command'
|
|
17
|
+
require '3scale_toolbox/commands/product_command'
|
|
16
18
|
|
|
17
19
|
module ThreeScaleToolbox
|
|
18
20
|
module Commands
|
|
@@ -31,6 +33,8 @@ module ThreeScaleToolbox
|
|
|
31
33
|
ThreeScaleToolbox::Commands::ProxyConfigCommand,
|
|
32
34
|
ThreeScaleToolbox::Commands::PolicyRegistryCommand,
|
|
33
35
|
ThreeScaleToolbox::Commands::ApplicationCommand,
|
|
36
|
+
ThreeScaleToolbox::Commands::BackendCommand,
|
|
37
|
+
ThreeScaleToolbox::Commands::ProductCommand,
|
|
34
38
|
].freeze
|
|
35
39
|
end
|
|
36
40
|
end
|
|
@@ -2,6 +2,24 @@ module ThreeScaleToolbox
|
|
|
2
2
|
module Commands
|
|
3
3
|
module ActiveDocsCommand
|
|
4
4
|
module Apply
|
|
5
|
+
class CustomPrinter
|
|
6
|
+
attr_reader :option_publish, :option_hide
|
|
7
|
+
|
|
8
|
+
def initialize(options)
|
|
9
|
+
@option_publish = options[:publish]
|
|
10
|
+
@option_hide = options[:hide]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def print_record(active_docs)
|
|
14
|
+
output_msg_array = ["Applied ActiveDocs id: #{active_docs['id']}"]
|
|
15
|
+
output_msg_array << 'Published' if option_publish
|
|
16
|
+
output_msg_array << 'Hidden' if option_hide
|
|
17
|
+
puts output_msg_array.join(';')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def print_collection(collection) end
|
|
21
|
+
end
|
|
22
|
+
|
|
5
23
|
class ApplySubcommand < Cri::CommandRunner
|
|
6
24
|
include ThreeScaleToolbox::Command
|
|
7
25
|
include ThreeScaleToolbox::ResourceReader
|
|
@@ -12,10 +30,6 @@ module ThreeScaleToolbox
|
|
|
12
30
|
usage 'apply <remote> <activedocs_id_or_system_name>'
|
|
13
31
|
summary 'Update activedocs'
|
|
14
32
|
description 'Create or update an ActiveDocs'
|
|
15
|
-
runner ApplySubcommand
|
|
16
|
-
|
|
17
|
-
param :remote
|
|
18
|
-
param :activedocs_id_or_system_name
|
|
19
33
|
|
|
20
34
|
option :i, :'service-id', "Specify the Service ID associated to the ActiveDocs", argument: :required
|
|
21
35
|
option :p, :'publish', "Specify it to publish the ActiveDocs on the Developer Portal. Otherwise it will be hidden", argument: :forbidden
|
|
@@ -24,22 +38,26 @@ module ThreeScaleToolbox
|
|
|
24
38
|
option :d, :'description', "Specify the description of the ActiveDocs", argument: :required
|
|
25
39
|
option :s, :'name', "Specify the name of the ActiveDocs", argument: :required
|
|
26
40
|
option nil, :'openapi-spec', "Specify the swagger spec. Can be a file, an URL or '-' to read from stdin. This option is mandatory when applying the ActiveDoc for the first time", argument: :required
|
|
41
|
+
|
|
42
|
+
param :remote
|
|
43
|
+
param :activedocs_id_or_system_name
|
|
44
|
+
|
|
45
|
+
ThreeScaleToolbox::CLI.output_flag(self)
|
|
46
|
+
|
|
47
|
+
runner ApplySubcommand
|
|
27
48
|
end
|
|
28
49
|
end
|
|
29
50
|
|
|
30
51
|
def run
|
|
31
|
-
res = activedocs
|
|
32
52
|
validate_option_params
|
|
53
|
+
res = activedocs
|
|
33
54
|
if !res
|
|
34
|
-
res = Entities::ActiveDocs
|
|
55
|
+
res = Entities::ActiveDocs.create(remote: remote, attrs: create_activedocs_attrs)
|
|
35
56
|
else
|
|
36
57
|
res.update(activedocs_attrs) unless activedocs_attrs.empty?
|
|
37
58
|
end
|
|
38
59
|
|
|
39
|
-
|
|
40
|
-
output_msg_array << "Published" if option_publish
|
|
41
|
-
output_msg_array << "Hidden" if option_hide
|
|
42
|
-
puts output_msg_array.join(";")
|
|
60
|
+
printer.print_record res.attrs
|
|
43
61
|
end
|
|
44
62
|
|
|
45
63
|
private
|
|
@@ -120,6 +138,11 @@ module ThreeScaleToolbox
|
|
|
120
138
|
"body" => activedocs_json_spec,
|
|
121
139
|
) { |_key, oldval, _newval| oldval } # receiver of the merge message has key priority
|
|
122
140
|
end
|
|
141
|
+
|
|
142
|
+
def printer
|
|
143
|
+
# keep backwards compatibility
|
|
144
|
+
options.fetch(:output, CustomPrinter.new(publish: option_publish, hide: option_hide))
|
|
145
|
+
end
|
|
123
146
|
end
|
|
124
147
|
end
|
|
125
148
|
end
|
|
@@ -2,6 +2,14 @@ module ThreeScaleToolbox
|
|
|
2
2
|
module Commands
|
|
3
3
|
module ActiveDocsCommand
|
|
4
4
|
module Create
|
|
5
|
+
class CustomPrinter
|
|
6
|
+
def print_record(activedocs)
|
|
7
|
+
puts "ActiveDocs '#{activedocs['name']}' has been created with ID: #{activedocs['id']}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def print_collection(collection) end
|
|
11
|
+
end
|
|
12
|
+
|
|
5
13
|
class CreateSubcommand < Cri::CommandRunner
|
|
6
14
|
include ThreeScaleToolbox::Command
|
|
7
15
|
include ThreeScaleToolbox::ResourceReader
|
|
@@ -12,23 +20,25 @@ module ThreeScaleToolbox
|
|
|
12
20
|
usage 'create <remote> <activedocs-name> <spec>'
|
|
13
21
|
summary 'Create an ActiveDocs'
|
|
14
22
|
description 'Create an ActiveDocs'
|
|
15
|
-
runner CreateSubcommand
|
|
16
|
-
|
|
17
|
-
param :remote
|
|
18
|
-
param :activedocs_name
|
|
19
|
-
param :activedocs_spec
|
|
20
23
|
|
|
21
24
|
option :i, :'service-id', "Specify the Service ID associated to the ActiveDocs", argument: :required
|
|
22
25
|
option :p, :'published', "Specify it to publish the ActiveDoc on the Developer Portal. Otherwise it will be hidden", argument: :forbidden
|
|
23
26
|
option nil, :'skip-swagger-validations', "Specify it to skip validation of the Swagger specification", argument: :forbidden
|
|
24
27
|
option :d, :'description', "Specify the description of the ActiveDocs", argument: :required
|
|
25
28
|
option :s, :'system-name', "Specify the system-name of the ActiveDocs", argument: :required
|
|
29
|
+
ThreeScaleToolbox::CLI.output_flag(self)
|
|
30
|
+
|
|
31
|
+
param :remote
|
|
32
|
+
param :activedocs_name
|
|
33
|
+
param :activedocs_spec
|
|
34
|
+
|
|
35
|
+
runner CreateSubcommand
|
|
26
36
|
end
|
|
27
37
|
end
|
|
28
38
|
|
|
29
39
|
def run
|
|
30
|
-
res = Entities::ActiveDocs
|
|
31
|
-
|
|
40
|
+
res = Entities::ActiveDocs.create(remote: remote, attrs: activedocs_attrs)
|
|
41
|
+
printer.print_record res.attrs
|
|
32
42
|
end
|
|
33
43
|
|
|
34
44
|
private
|
|
@@ -58,6 +68,11 @@ module ThreeScaleToolbox
|
|
|
58
68
|
"body" => activedocs_json_spec,
|
|
59
69
|
}.compact
|
|
60
70
|
end
|
|
71
|
+
|
|
72
|
+
def printer
|
|
73
|
+
# keep backwards compatibility
|
|
74
|
+
options.fetch(:output, CustomPrinter.new)
|
|
75
|
+
end
|
|
61
76
|
end
|
|
62
77
|
end
|
|
63
78
|
end
|
|
@@ -11,16 +11,17 @@ module ThreeScaleToolbox
|
|
|
11
11
|
usage 'list <remote>'
|
|
12
12
|
summary 'List ActiveDocs'
|
|
13
13
|
description 'List all defined ActiveDocs'
|
|
14
|
-
runner ListSubcommand
|
|
15
14
|
|
|
15
|
+
ThreeScaleToolbox::CLI.output_flag(self)
|
|
16
16
|
param :remote
|
|
17
17
|
option :s, :'service-ref', "Filter the ActiveDocs by Service reference", argument: :required
|
|
18
|
+
|
|
19
|
+
runner ListSubcommand
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def run
|
|
22
|
-
|
|
23
|
-
print_activedocs_data(activedocs, ACTIVEDOCS_FIELDS_TO_SHOW)
|
|
24
|
+
printer.print_collection filtered_activedocs
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
private
|
|
@@ -34,13 +35,9 @@ module ThreeScaleToolbox
|
|
|
34
35
|
@remote ||= threescale_client(arguments[:remote])
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def print_header(fields_to_show)
|
|
43
|
-
puts fields_to_show.map { |e| e.upcase }.join("\t")
|
|
38
|
+
def printer
|
|
39
|
+
# keep backwards compatibility
|
|
40
|
+
options.fetch(:output, CLI::CustomTablePrinter.new(ACTIVEDOCS_FIELDS_TO_SHOW))
|
|
44
41
|
end
|
|
45
42
|
|
|
46
43
|
def service_ref_filter
|
|
@@ -55,13 +52,9 @@ module ThreeScaleToolbox
|
|
|
55
52
|
res
|
|
56
53
|
end
|
|
57
54
|
|
|
58
|
-
def filtered_activedocs
|
|
59
|
-
filters.reduce(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def print_results(activedocs, fields_to_show)
|
|
63
|
-
filtered_activedocs(activedocs).each do |activedoc|
|
|
64
|
-
puts fields_to_show.map { |field| activedoc.fetch(field, '(empty)') }.join("\t")
|
|
55
|
+
def filtered_activedocs
|
|
56
|
+
filters.reduce(remote.list_activedocs) do |current_list, filter|
|
|
57
|
+
filter.filter(current_list)
|
|
65
58
|
end
|
|
66
59
|
end
|
|
67
60
|
end
|
|
@@ -2,6 +2,24 @@ module ThreeScaleToolbox
|
|
|
2
2
|
module Commands
|
|
3
3
|
module ApplicationCommand
|
|
4
4
|
module Apply
|
|
5
|
+
class CustomPrinter
|
|
6
|
+
attr_reader :option_resume, :option_suspend
|
|
7
|
+
|
|
8
|
+
def initialize(options)
|
|
9
|
+
@option_resume = options[:resume]
|
|
10
|
+
@option_suspend = options[:suspend]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def print_record(application)
|
|
14
|
+
output_msg_array = ["Applied application id: #{application['id']}"]
|
|
15
|
+
output_msg_array << 'Resumed' if option_resume
|
|
16
|
+
output_msg_array << 'Suspended' if option_suspend
|
|
17
|
+
puts output_msg_array.join('; ')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def print_collection(collection) end
|
|
21
|
+
end
|
|
22
|
+
|
|
5
23
|
class ApplySubcommand < Cri::CommandRunner
|
|
6
24
|
include ThreeScaleToolbox::Command
|
|
7
25
|
|
|
@@ -28,6 +46,8 @@ module ThreeScaleToolbox
|
|
|
28
46
|
option nil, :'redirect-url', 'OpenID Connect redirect url', argument: :required
|
|
29
47
|
flag nil, :resume, 'Resume a suspended application'
|
|
30
48
|
flag nil, :suspend, 'Suspends an application (changes the state to suspended)'
|
|
49
|
+
ThreeScaleToolbox::CLI.output_flag(self)
|
|
50
|
+
|
|
31
51
|
param :remote
|
|
32
52
|
param :application
|
|
33
53
|
|
|
@@ -52,10 +72,8 @@ module ThreeScaleToolbox
|
|
|
52
72
|
|
|
53
73
|
application.resume if option_resume
|
|
54
74
|
application.suspend if option_suspend
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
output_msg_array << 'Suspended' if option_suspend
|
|
58
|
-
puts output_msg_array.join('; ')
|
|
75
|
+
|
|
76
|
+
printer.print_record application.attrs
|
|
59
77
|
end
|
|
60
78
|
|
|
61
79
|
private
|
|
@@ -186,6 +204,11 @@ module ThreeScaleToolbox
|
|
|
186
204
|
def option_redirect_url
|
|
187
205
|
options[:'redirect-url']
|
|
188
206
|
end
|
|
207
|
+
|
|
208
|
+
def printer
|
|
209
|
+
# keep backwards compatibility
|
|
210
|
+
options.fetch(:output, CustomPrinter.new(resume: option_resume, suspend: option_suspend))
|
|
211
|
+
end
|
|
189
212
|
end
|
|
190
213
|
end
|
|
191
214
|
end
|
|
@@ -2,6 +2,14 @@ module ThreeScaleToolbox
|
|
|
2
2
|
module Commands
|
|
3
3
|
module ApplicationCommand
|
|
4
4
|
module Create
|
|
5
|
+
class CustomPrinter
|
|
6
|
+
def print_record(application)
|
|
7
|
+
puts "Created application id: #{application['id']}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def print_collection(collection) end
|
|
11
|
+
end
|
|
12
|
+
|
|
5
13
|
class CreateSubcommand < Cri::CommandRunner
|
|
6
14
|
include ThreeScaleToolbox::Command
|
|
7
15
|
|
|
@@ -17,6 +25,8 @@ module ThreeScaleToolbox
|
|
|
17
25
|
option nil, 'application-key', 'App Key(s) or Client Secret (for OAuth and OpenID Connect authentication modes) of the application to be created.' , argument: :required
|
|
18
26
|
option nil, :description, 'Application description', argument: :required
|
|
19
27
|
option nil, :'redirect-url', 'OpenID Connect redirect url', argument: :required
|
|
28
|
+
ThreeScaleToolbox::CLI.output_flag(self)
|
|
29
|
+
|
|
20
30
|
param :remote
|
|
21
31
|
param :account
|
|
22
32
|
param :service
|
|
@@ -35,7 +45,7 @@ module ThreeScaleToolbox
|
|
|
35
45
|
app_attrs: app_attrs
|
|
36
46
|
)
|
|
37
47
|
|
|
38
|
-
|
|
48
|
+
printer.print_record application.attrs
|
|
39
49
|
end
|
|
40
50
|
|
|
41
51
|
private
|
|
@@ -105,6 +115,11 @@ module ThreeScaleToolbox
|
|
|
105
115
|
def remote
|
|
106
116
|
@remote ||= threescale_client(arguments[:remote])
|
|
107
117
|
end
|
|
118
|
+
|
|
119
|
+
def printer
|
|
120
|
+
# keep backwards compatibility
|
|
121
|
+
options.fetch(:output, CustomPrinter.new)
|
|
122
|
+
end
|
|
108
123
|
end
|
|
109
124
|
end
|
|
110
125
|
end
|