3scale_toolbox 0.10.0 → 0.11.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/README.md +21 -144
- data/lib/3scale_toolbox.rb +0 -1
- data/lib/3scale_toolbox/commands.rb +12 -0
- data/lib/3scale_toolbox/commands/3scale_command.rb +1 -1
- data/lib/3scale_toolbox/commands/account_command.rb +23 -0
- data/lib/3scale_toolbox/commands/account_command/find_command.rb +41 -0
- data/lib/3scale_toolbox/commands/activedocs_command.rb +32 -0
- data/lib/3scale_toolbox/commands/activedocs_command/apply_command.rb +127 -0
- data/lib/3scale_toolbox/commands/activedocs_command/create_command.rb +65 -0
- data/lib/3scale_toolbox/commands/activedocs_command/delete_command.rb +49 -0
- data/lib/3scale_toolbox/commands/activedocs_command/list_command.rb +54 -0
- data/lib/3scale_toolbox/commands/application_command.rb +30 -0
- data/lib/3scale_toolbox/commands/application_command/apply_command.rb +179 -0
- data/lib/3scale_toolbox/commands/application_command/create_command.rb +110 -0
- data/lib/3scale_toolbox/commands/application_command/delete_command.rb +57 -0
- data/lib/3scale_toolbox/commands/application_command/list_command.rb +124 -0
- data/lib/3scale_toolbox/commands/application_command/show_command.rb +72 -0
- data/lib/3scale_toolbox/commands/copy_command/copy_service.rb +97 -28
- data/lib/3scale_toolbox/commands/import_command/import_csv.rb +16 -17
- data/lib/3scale_toolbox/commands/import_command/openapi.rb +14 -10
- data/lib/3scale_toolbox/commands/import_command/openapi/create_service_step.rb +3 -2
- data/lib/3scale_toolbox/commands/import_command/openapi/method.rb +0 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/step.rb +8 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/update_service_proxy_step.rb +17 -7
- data/lib/3scale_toolbox/commands/methods_command.rb +4 -4
- data/lib/3scale_toolbox/commands/methods_command/apply_command.rb +2 -2
- data/lib/3scale_toolbox/commands/methods_command/create_command.rb +1 -1
- data/lib/3scale_toolbox/commands/metrics_command.rb +4 -4
- data/lib/3scale_toolbox/commands/metrics_command/apply_command.rb +2 -2
- data/lib/3scale_toolbox/commands/metrics_command/create_command.rb +1 -1
- data/lib/3scale_toolbox/commands/plans_command/apply_command.rb +7 -7
- data/lib/3scale_toolbox/commands/plans_command/create_command.rb +5 -5
- data/lib/3scale_toolbox/commands/policy_registry_command.rb +22 -0
- data/lib/3scale_toolbox/commands/policy_registry_command/copy_command.rb +85 -0
- data/lib/3scale_toolbox/commands/proxy_config_command.rb +30 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/list_command.rb +78 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/promote_command.rb +68 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/show_command.rb +88 -0
- data/lib/3scale_toolbox/commands/service_command.rb +34 -0
- data/lib/3scale_toolbox/commands/service_command/apply_command.rb +77 -0
- data/lib/3scale_toolbox/commands/service_command/create_command.rb +59 -0
- data/lib/3scale_toolbox/commands/service_command/delete_command.rb +49 -0
- data/lib/3scale_toolbox/commands/service_command/list_command.rb +50 -0
- data/lib/3scale_toolbox/commands/service_command/show_command.rb +63 -0
- data/lib/3scale_toolbox/commands/update_command/update_service.rb +6 -3
- data/lib/3scale_toolbox/entities.rb +4 -0
- data/lib/3scale_toolbox/entities/account.rb +63 -0
- data/lib/3scale_toolbox/entities/activedocs.rb +88 -0
- data/lib/3scale_toolbox/entities/application.rb +124 -0
- data/lib/3scale_toolbox/entities/application_plan.rb +28 -4
- data/lib/3scale_toolbox/entities/base_entity.rb +44 -0
- data/lib/3scale_toolbox/entities/proxy_config.rb +58 -0
- data/lib/3scale_toolbox/entities/service.rb +42 -8
- data/lib/3scale_toolbox/error.rb +8 -0
- data/lib/3scale_toolbox/tasks.rb +2 -1
- data/lib/3scale_toolbox/tasks/bump_proxy_version_task.rb +32 -0
- data/lib/3scale_toolbox/tasks/copy_service_settings_task.rb +38 -0
- data/lib/3scale_toolbox/version.rb +1 -1
- metadata +36 -5
- data/lib/3scale_toolbox/tasks/update_service_settings_task.rb +0 -49
@@ -0,0 +1,65 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ActiveDocsCommand
|
4
|
+
module Create
|
5
|
+
class CreateSubcommand < Cri::CommandRunner
|
6
|
+
include ThreeScaleToolbox::Command
|
7
|
+
include ThreeScaleToolbox::ResourceReader
|
8
|
+
|
9
|
+
def self.command
|
10
|
+
Cri::Command.define do
|
11
|
+
name 'create'
|
12
|
+
usage 'create <remote> <activedocs-name> <spec>'
|
13
|
+
summary 'Create an ActiveDocs'
|
14
|
+
description 'Create an ActiveDocs'
|
15
|
+
runner CreateSubcommand
|
16
|
+
|
17
|
+
param :remote
|
18
|
+
param :activedocs_name
|
19
|
+
param :activedocs_spec
|
20
|
+
|
21
|
+
option :i, :'service-id', "Specify the Service ID associated to the ActiveDocs", argument: :required
|
22
|
+
option :p, :'published', "Specify it to publish the ActiveDoc on the Developer Portal. Otherwise it will be hidden", argument: :forbidden
|
23
|
+
option nil, :'skip-swagger-validations', "Specify it to skip validation of the Swagger specification", argument: :forbidden
|
24
|
+
option :d, :'description', "Specify the description of the ActiveDocs", argument: :required
|
25
|
+
option :s, :'system-name', "Specify the system-name of the ActiveDocs", argument: :required
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
res = Entities::ActiveDocs::create(remote: remote, attrs: activedocs_attrs)
|
31
|
+
puts "ActiveDocs '#{activedocs_name}' has been created with ID: #{res.id}"
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def activedocs_name
|
37
|
+
arguments[:activedocs_name]
|
38
|
+
end
|
39
|
+
|
40
|
+
def remote
|
41
|
+
@remote ||= threescale_client(arguments[:remote])
|
42
|
+
end
|
43
|
+
|
44
|
+
def activedocs_json_spec
|
45
|
+
activedoc_spec = arguments[:activedocs_spec]
|
46
|
+
activedoc_spec_content = load_resource(arguments[:activedocs_spec])
|
47
|
+
JSON.pretty_generate(activedoc_spec_content)
|
48
|
+
end
|
49
|
+
|
50
|
+
def activedocs_attrs
|
51
|
+
{
|
52
|
+
"service_id" => options[:'service-id'],
|
53
|
+
"published" => options[:'published'],
|
54
|
+
"skip_swagger_validations" => options[:'skip-swagger-validations'],
|
55
|
+
"description" => options[:'description'],
|
56
|
+
"system_name" => options[:'system-name'],
|
57
|
+
"name" => activedocs_name,
|
58
|
+
"body" => activedocs_json_spec,
|
59
|
+
}.compact
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ActiveDocsCommand
|
4
|
+
module Delete
|
5
|
+
class DeleteSubcommand < Cri::CommandRunner
|
6
|
+
include ThreeScaleToolbox::Command
|
7
|
+
|
8
|
+
def self.command
|
9
|
+
Cri::Command.define do
|
10
|
+
name 'delete'
|
11
|
+
usage 'delete <remote> <activedocs-id_or-system-name>'
|
12
|
+
summary 'Delete an ActiveDocs'
|
13
|
+
description 'Remove an ActiveDocs'
|
14
|
+
runner DeleteSubcommand
|
15
|
+
|
16
|
+
param :remote
|
17
|
+
param :activedocs_id_or_system_name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
activedocs.delete
|
23
|
+
puts "ActiveDocs with id: #{activedocs.id} deleted"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def remote
|
29
|
+
@remote ||= threescale_client(arguments[:remote])
|
30
|
+
end
|
31
|
+
|
32
|
+
def ref
|
33
|
+
arguments[:activedocs_id_or_system_name]
|
34
|
+
end
|
35
|
+
|
36
|
+
def activedocs
|
37
|
+
@activedocs ||= find_activedocs
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_activedocs
|
41
|
+
Entities::ActiveDocs.find(remote: remote, ref: ref).tap do |activedoc|
|
42
|
+
raise ThreeScaleToolbox::Error, "ActiveDocs #{ref} does not exist" if activedoc.nil?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ActiveDocsCommand
|
4
|
+
module List
|
5
|
+
class ListSubcommand < Cri::CommandRunner
|
6
|
+
include ThreeScaleToolbox::Command
|
7
|
+
|
8
|
+
def self.command
|
9
|
+
Cri::Command.define do
|
10
|
+
name 'list'
|
11
|
+
usage 'list <remote>'
|
12
|
+
summary 'List ActiveDocs'
|
13
|
+
description 'List all defined ActiveDocs'
|
14
|
+
runner ListSubcommand
|
15
|
+
|
16
|
+
param :remote
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
activedocs = remote.list_activedocs
|
22
|
+
print_activedocs_data(activedocs, ACTIVEDOCS_FIELDS_TO_SHOW)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
ACTIVEDOCS_FIELDS_TO_SHOW = %w[
|
28
|
+
id name system_name service_id published
|
29
|
+
skip_swagger_validations created_at updated_at
|
30
|
+
]
|
31
|
+
|
32
|
+
def remote
|
33
|
+
@remote ||= threescale_client(arguments[:remote])
|
34
|
+
end
|
35
|
+
|
36
|
+
def print_activedocs_data(activedocs, fields_to_show)
|
37
|
+
print_header(fields_to_show)
|
38
|
+
print_results(activedocs, fields_to_show)
|
39
|
+
end
|
40
|
+
|
41
|
+
def print_header(fields_to_show)
|
42
|
+
puts fields_to_show.map { |e| e.upcase }.join("\t")
|
43
|
+
end
|
44
|
+
|
45
|
+
def print_results(activedocs, fields_to_show)
|
46
|
+
activedocs.each do |activedoc|
|
47
|
+
puts fields_to_show.map { |field| activedoc.fetch(field, '(empty)') }.join("\t")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require '3scale_toolbox/commands/application_command/list_command'
|
2
|
+
require '3scale_toolbox/commands/application_command/create_command'
|
3
|
+
require '3scale_toolbox/commands/application_command/show_command'
|
4
|
+
require '3scale_toolbox/commands/application_command/apply_command'
|
5
|
+
require '3scale_toolbox/commands/application_command/delete_command'
|
6
|
+
|
7
|
+
module ThreeScaleToolbox
|
8
|
+
module Commands
|
9
|
+
module ApplicationCommand
|
10
|
+
include ThreeScaleToolbox::Command
|
11
|
+
def self.command
|
12
|
+
Cri::Command.define do
|
13
|
+
name 'application'
|
14
|
+
usage 'application <sub-command> [options]'
|
15
|
+
summary 'application super command'
|
16
|
+
description 'application commands'
|
17
|
+
|
18
|
+
run do |_opts, _args, cmd|
|
19
|
+
puts cmd.help
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
add_subcommand(List::ListSubcommand)
|
24
|
+
add_subcommand(Create::CreateSubcommand)
|
25
|
+
add_subcommand(Show::ShowSubcommand)
|
26
|
+
add_subcommand(Apply::ApplySubcommand)
|
27
|
+
add_subcommand(Delete::DeleteSubcommand)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ApplicationCommand
|
4
|
+
module Apply
|
5
|
+
class ApplySubcommand < Cri::CommandRunner
|
6
|
+
include ThreeScaleToolbox::Command
|
7
|
+
|
8
|
+
def self.command
|
9
|
+
Cri::Command.define do
|
10
|
+
name 'apply'
|
11
|
+
usage 'apply [opts] <remote> <application>'
|
12
|
+
summary 'update (or create) application'
|
13
|
+
description <<-HEREDOC
|
14
|
+
Update (create if it does not exist) application'
|
15
|
+
\n Application param allows:
|
16
|
+
\n * Application internal id
|
17
|
+
\n * User_key (API key)
|
18
|
+
\n * App_id (from app_id/app_key pair)
|
19
|
+
\n * Client ID (for OAuth and OpenID Connect authentication modes)
|
20
|
+
HEREDOC
|
21
|
+
|
22
|
+
option nil, 'user-key', 'User Key (API Key) of the application to be created.', argument: :required
|
23
|
+
option nil, 'application-key', 'App Key(s) or Client Secret (for OAuth and OpenID Connect authentication modes) of the application to be created. Only used when application does not exist.' , argument: :required
|
24
|
+
option nil, :description, 'Application description', argument: :required
|
25
|
+
option nil, :name, 'Application name', argument: :required
|
26
|
+
option nil, :account, 'Application\'s account. Required when creating', argument: :required
|
27
|
+
option nil, :service, 'Application\'s service. Required when creating', argument: :required
|
28
|
+
option nil, :plan, 'Application\'s plan. Required when creating', argument: :required
|
29
|
+
flag nil, :resume, 'Resume a suspended application'
|
30
|
+
flag nil, :suspend, 'Suspends an application (changes the state to suspended)'
|
31
|
+
param :remote
|
32
|
+
param :application
|
33
|
+
|
34
|
+
runner ApplySubcommand
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def run
|
39
|
+
validate_option_params
|
40
|
+
|
41
|
+
application = Entities::Application.find(remote: remote, ref: application_ref)
|
42
|
+
if application.nil?
|
43
|
+
validate_creation_option_params
|
44
|
+
application = Entities::Application.create(remote: remote,
|
45
|
+
account_id: account.id,
|
46
|
+
plan_id: plan.id,
|
47
|
+
app_attrs: create_app_attrs)
|
48
|
+
else
|
49
|
+
application.update(app_attrs) unless app_attrs.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
application.resume if option_resume
|
53
|
+
application.suspend if option_suspend
|
54
|
+
output_msg_array = ["Applied application id: #{application.id}"]
|
55
|
+
output_msg_array << 'Resumed' if option_resume
|
56
|
+
output_msg_array << 'Suspended' if option_suspend
|
57
|
+
puts output_msg_array.join('; ')
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def validate_option_params
|
63
|
+
raise ThreeScaleToolbox::Error, '--resume and --suspend are mutually exclusive' \
|
64
|
+
if option_resume && option_suspend
|
65
|
+
end
|
66
|
+
|
67
|
+
def validate_creation_option_params
|
68
|
+
raise ThreeScaleToolbox::Error, "Application #{application_ref} does not exist." \
|
69
|
+
'--account is required to create' if option_account.nil?
|
70
|
+
raise ThreeScaleToolbox::Error, "Application #{application_ref} does not exist." \
|
71
|
+
'--service is required to create' if option_service.nil?
|
72
|
+
raise ThreeScaleToolbox::Error, "Application #{application_ref} does not exist." \
|
73
|
+
'--plan is required to create' if option_plan.nil?
|
74
|
+
raise ThreeScaleToolbox::Error, "Application #{application_ref} does not exist." \
|
75
|
+
'--name is required to create' if option_name.nil?
|
76
|
+
raise ThreeScaleToolbox::Error, "Application #{application_ref} does not exist." \
|
77
|
+
'--user-key option forbidden' unless option_user_key.nil?
|
78
|
+
end
|
79
|
+
|
80
|
+
def create_app_attrs
|
81
|
+
{
|
82
|
+
'name' => option_name,
|
83
|
+
'description' => description,
|
84
|
+
'user_key' => application_ref,
|
85
|
+
'application_id' => application_ref,
|
86
|
+
'application_key' => option_app_key,
|
87
|
+
}.compact
|
88
|
+
end
|
89
|
+
|
90
|
+
def app_attrs
|
91
|
+
# This apply command does not update App Key (or Client Secret).
|
92
|
+
# Hence, not included.
|
93
|
+
{
|
94
|
+
'name' => option_name,
|
95
|
+
'description' => description,
|
96
|
+
'user_key' => option_user_key,
|
97
|
+
}.compact
|
98
|
+
end
|
99
|
+
|
100
|
+
def account
|
101
|
+
@account ||= find_account
|
102
|
+
end
|
103
|
+
|
104
|
+
def find_account
|
105
|
+
Entities::Account.find(remote: remote,
|
106
|
+
ref: option_account).tap do |acc|
|
107
|
+
raise ThreeScaleToolbox::Error, "Account #{option_account} does not exist" if acc.nil?
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def service
|
112
|
+
@service ||= find_service
|
113
|
+
end
|
114
|
+
|
115
|
+
def find_service
|
116
|
+
Entities::Service.find(remote: remote,
|
117
|
+
ref: option_service).tap do |svc|
|
118
|
+
raise ThreeScaleToolbox::Error, "Service #{option_service} does not exist" if svc.nil?
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def plan
|
123
|
+
@plan ||= find_plan
|
124
|
+
end
|
125
|
+
|
126
|
+
def find_plan
|
127
|
+
Entities::ApplicationPlan.find(service: service, ref: option_plan).tap do |pl|
|
128
|
+
raise ThreeScaleToolbox::Error, "Application plan #{option_plan} does not exist" if pl.nil?
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def remote
|
133
|
+
@remote ||= threescale_client(arguments[:remote])
|
134
|
+
end
|
135
|
+
|
136
|
+
def option_name
|
137
|
+
options[:name]
|
138
|
+
end
|
139
|
+
|
140
|
+
def description
|
141
|
+
options[:description] || option_name
|
142
|
+
end
|
143
|
+
|
144
|
+
def option_user_key
|
145
|
+
options[:'user-key']
|
146
|
+
end
|
147
|
+
|
148
|
+
def option_app_key
|
149
|
+
options[:'application-key']
|
150
|
+
end
|
151
|
+
|
152
|
+
def option_account
|
153
|
+
options[:account]
|
154
|
+
end
|
155
|
+
|
156
|
+
def option_service
|
157
|
+
options[:service]
|
158
|
+
end
|
159
|
+
|
160
|
+
def option_plan
|
161
|
+
options[:plan]
|
162
|
+
end
|
163
|
+
|
164
|
+
def option_resume
|
165
|
+
options.fetch(:resume, false)
|
166
|
+
end
|
167
|
+
|
168
|
+
def option_suspend
|
169
|
+
options.fetch(:suspend, false)
|
170
|
+
end
|
171
|
+
|
172
|
+
def application_ref
|
173
|
+
arguments[:application]
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module Commands
|
3
|
+
module ApplicationCommand
|
4
|
+
module Create
|
5
|
+
class CreateSubcommand < Cri::CommandRunner
|
6
|
+
include ThreeScaleToolbox::Command
|
7
|
+
|
8
|
+
def self.command
|
9
|
+
Cri::Command.define do
|
10
|
+
name 'create'
|
11
|
+
usage 'create [opts] <remote> <account> <service> <application-plan> <name>'
|
12
|
+
summary 'create one application'
|
13
|
+
description 'create one application linked to given account and application plan'
|
14
|
+
|
15
|
+
option nil, 'user-key', 'User Key (API Key) of the application to be created.', argument: :required
|
16
|
+
option nil, 'application-id', 'App ID or Client ID (for OAuth and OpenID Connect authentication modes) of the application to be created. ', argument: :required
|
17
|
+
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
|
+
option nil, :description, 'Application description', argument: :required
|
19
|
+
param :remote
|
20
|
+
param :account
|
21
|
+
param :service
|
22
|
+
param :plan
|
23
|
+
param :name
|
24
|
+
|
25
|
+
runner CreateSubcommand
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
application = ThreeScaleToolbox::Entities::Application.create(
|
31
|
+
remote: remote,
|
32
|
+
account_id: account.id,
|
33
|
+
plan_id: plan.id,
|
34
|
+
app_attrs: app_attrs
|
35
|
+
)
|
36
|
+
|
37
|
+
puts "Created application id: #{application.id}"
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def app_attrs
|
43
|
+
{
|
44
|
+
'name' => name,
|
45
|
+
'description' => description,
|
46
|
+
'user_key' => options[:'user-key'],
|
47
|
+
'application_id' => options[:'application-id'],
|
48
|
+
'application_key' => options[:'application-key']
|
49
|
+
}.compact
|
50
|
+
end
|
51
|
+
|
52
|
+
def description
|
53
|
+
options[:description] || name
|
54
|
+
end
|
55
|
+
|
56
|
+
def name
|
57
|
+
arguments[:name]
|
58
|
+
end
|
59
|
+
|
60
|
+
def account_ref
|
61
|
+
arguments[:account]
|
62
|
+
end
|
63
|
+
|
64
|
+
def account
|
65
|
+
@account ||= find_account
|
66
|
+
end
|
67
|
+
|
68
|
+
def find_account
|
69
|
+
Entities::Account.find(remote: remote,
|
70
|
+
ref: account_ref).tap do |acc|
|
71
|
+
raise ThreeScaleToolbox::Error, "Account #{account_ref} does not exist" if acc.nil?
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def service_ref
|
76
|
+
arguments[:service]
|
77
|
+
end
|
78
|
+
|
79
|
+
def service
|
80
|
+
@service ||= find_service
|
81
|
+
end
|
82
|
+
|
83
|
+
def find_service
|
84
|
+
Entities::Service.find(remote: remote, ref: service_ref).tap do |svc|
|
85
|
+
raise ThreeScaleToolbox::Error, "Service #{service_ref} does not exist" if svc.nil?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def plan_ref
|
90
|
+
arguments[:plan]
|
91
|
+
end
|
92
|
+
|
93
|
+
def plan
|
94
|
+
@plan ||= find_plan
|
95
|
+
end
|
96
|
+
|
97
|
+
def find_plan
|
98
|
+
Entities::ApplicationPlan.find(service: service, ref: plan_ref).tap do |plan|
|
99
|
+
raise ThreeScaleToolbox::Error, "Application plan #{plan_ref} does not exist" if plan.nil?
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def remote
|
104
|
+
@remote ||= threescale_client(arguments[:remote])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|