3scale_toolbox 0.16.0 → 0.18.3
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 +2 -2
- data/README.md +11 -8
- data/lib/3scale_toolbox.rb +3 -0
- data/lib/3scale_toolbox/3scale_client_factory.rb +3 -4
- data/lib/3scale_toolbox/cli/error_handler.rb +17 -14
- data/lib/3scale_toolbox/commands.rb +2 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_mapping_rules_task.rb +11 -27
- data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_methods_task.rb +5 -10
- data/lib/3scale_toolbox/commands/backend_command/copy_command/copy_metrics_task.rb +4 -4
- data/lib/3scale_toolbox/commands/backend_command/copy_command/create_or_update_target_backend_task.rb +3 -2
- data/lib/3scale_toolbox/commands/backend_command/copy_command/task.rb +10 -32
- data/lib/3scale_toolbox/commands/import_command/issuer_type_transformer.rb +16 -0
- data/lib/3scale_toolbox/commands/import_command/openapi.rb +3 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/create_activedocs_step.rb +3 -2
- data/lib/3scale_toolbox/commands/import_command/openapi/create_mapping_rule_step.rb +2 -1
- data/lib/3scale_toolbox/commands/import_command/openapi/create_method_step.rb +5 -14
- data/lib/3scale_toolbox/commands/import_command/openapi/step.rb +4 -0
- data/lib/3scale_toolbox/commands/import_command/openapi/update_service_proxy_step.rb +1 -0
- data/lib/3scale_toolbox/commands/methods_command/apply_command.rb +2 -4
- data/lib/3scale_toolbox/commands/methods_command/create_command.rb +0 -2
- data/lib/3scale_toolbox/commands/methods_command/delete_command.rb +1 -1
- data/lib/3scale_toolbox/commands/methods_command/list_command.rb +1 -9
- data/lib/3scale_toolbox/commands/metrics_command/list_command.rb +1 -1
- data/lib/3scale_toolbox/commands/plans_command/export/read_plan_limits_step.rb +1 -1
- data/lib/3scale_toolbox/commands/plans_command/export/read_plan_methods_step.rb +2 -2
- data/lib/3scale_toolbox/commands/plans_command/export/read_plan_metrics_step.rb +2 -2
- data/lib/3scale_toolbox/commands/plans_command/export/read_plan_pricing_rules_step.rb +1 -2
- data/lib/3scale_toolbox/commands/plans_command/export/step.rb +8 -20
- data/lib/3scale_toolbox/commands/plans_command/import/import_plan_limits_step.rb +12 -14
- data/lib/3scale_toolbox/commands/plans_command/import/import_plan_metrics_step.rb +6 -13
- data/lib/3scale_toolbox/commands/plans_command/import/import_plan_pricing_rules_step.rb +12 -20
- data/lib/3scale_toolbox/commands/plans_command/import/step.rb +2 -22
- data/lib/3scale_toolbox/commands/plans_command/list_command.rb +1 -1
- data/lib/3scale_toolbox/commands/plans_command/show_command.rb +1 -1
- data/lib/3scale_toolbox/commands/policies_command.rb +24 -0
- data/lib/3scale_toolbox/commands/policies_command/export_command.rb +98 -0
- data/lib/3scale_toolbox/commands/policies_command/import_command.rb +61 -0
- data/lib/3scale_toolbox/commands/product_command.rb +4 -0
- data/lib/3scale_toolbox/commands/product_command/copy_command.rb +7 -3
- data/lib/3scale_toolbox/commands/product_command/copy_command/copy_backends_task.rb +22 -5
- data/lib/3scale_toolbox/commands/product_command/export_command.rb +81 -0
- data/lib/3scale_toolbox/commands/product_command/import_command.rb +125 -0
- data/lib/3scale_toolbox/commands/proxy_config_command.rb +5 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/deploy_command.rb +54 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/export_command.rb +74 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/helper.rb +15 -0
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_activedocs_task.rb +15 -12
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_app_plans_task.rb +15 -15
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_limits_task.rb +12 -13
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_mapping_rules_task.rb +11 -11
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_methods_task.rb +9 -12
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_metrics_task.rb +8 -8
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_policies_task.rb +1 -1
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_pricingrules_task.rb +15 -18
- data/lib/3scale_toolbox/commands/service_command/copy_command/copy_service_proxy_task.rb +17 -2
- data/lib/3scale_toolbox/commands/service_command/copy_command/create_or_update_service_task.rb +2 -1
- data/lib/3scale_toolbox/commands/service_command/copy_command/destroy_mapping_rules_task.rb +9 -5
- data/lib/3scale_toolbox/commands/service_command/copy_command/task.rb +20 -34
- data/lib/3scale_toolbox/commands/update_command.rb +1 -1
- data/lib/3scale_toolbox/commands/update_command/service_command.rb +3 -2
- data/lib/3scale_toolbox/commands/update_command/service_command/delete_activedocs_task.rb +1 -3
- data/lib/3scale_toolbox/crds.rb +16 -0
- data/lib/3scale_toolbox/crds/application_plan_dump.rb +19 -0
- data/lib/3scale_toolbox/crds/backend_dump.rb +39 -0
- data/lib/3scale_toolbox/crds/backend_mapping_rule_dump.rb +26 -0
- data/lib/3scale_toolbox/crds/backend_method_dump.rb +12 -0
- data/lib/3scale_toolbox/crds/backend_metric_dump.rb +13 -0
- data/lib/3scale_toolbox/crds/backend_parser.rb +55 -0
- data/lib/3scale_toolbox/crds/backend_usage_dump.rb +11 -0
- data/lib/3scale_toolbox/crds/limit_dump.rb +37 -0
- data/lib/3scale_toolbox/crds/mapping_rule_dump.rb +26 -0
- data/lib/3scale_toolbox/crds/method_dump.rb +12 -0
- data/lib/3scale_toolbox/crds/metric_dump.rb +13 -0
- data/lib/3scale_toolbox/crds/pricing_rule_dump.rb +38 -0
- data/lib/3scale_toolbox/crds/product_deployment_parser.rb +329 -0
- data/lib/3scale_toolbox/crds/product_dump.rb +157 -0
- data/lib/3scale_toolbox/crds/product_parser.rb +114 -0
- data/lib/3scale_toolbox/crds/remote.rb +682 -0
- data/lib/3scale_toolbox/entities.rb +3 -0
- data/lib/3scale_toolbox/entities/activedocs.rb +12 -0
- data/lib/3scale_toolbox/entities/application_plan.rb +74 -39
- data/lib/3scale_toolbox/entities/backend.rb +65 -30
- data/lib/3scale_toolbox/entities/backend_mapping_rule.rb +29 -3
- data/lib/3scale_toolbox/entities/backend_method.rb +25 -16
- data/lib/3scale_toolbox/entities/backend_metric.rb +12 -2
- data/lib/3scale_toolbox/entities/backend_usage.rb +7 -1
- data/lib/3scale_toolbox/entities/limit.rb +71 -0
- data/lib/3scale_toolbox/entities/mapping_rule.rb +90 -0
- data/lib/3scale_toolbox/entities/method.rb +33 -19
- data/lib/3scale_toolbox/entities/metric.rb +29 -18
- data/lib/3scale_toolbox/entities/pricing_rule.rb +63 -0
- data/lib/3scale_toolbox/entities/proxy_config.rb +0 -1
- data/lib/3scale_toolbox/entities/service.rb +149 -46
- data/lib/3scale_toolbox/error.rb +50 -0
- data/lib/3scale_toolbox/helper.rb +13 -16
- data/lib/3scale_toolbox/openapi/oas3.rb +1 -1
- data/lib/3scale_toolbox/proxy_logger.rb +4 -0
- data/lib/3scale_toolbox/remote_cache.rb +157 -0
- data/lib/3scale_toolbox/remotes.rb +2 -2
- data/lib/3scale_toolbox/version.rb +1 -1
- data/licenses.xml +113 -45
- metadata +37 -8
@@ -7,18 +7,13 @@ module ThreeScaleToolbox
|
|
7
7
|
|
8
8
|
def call
|
9
9
|
missing_operations.each do |op|
|
10
|
-
method = Entities::Method.create(service: service,
|
11
|
-
attrs: op.method)
|
10
|
+
method = Entities::Method.create(service: service, attrs: op.method)
|
12
11
|
op.set(:metric_id, method.id)
|
13
12
|
end
|
14
13
|
|
15
14
|
existing_operations.each do |op|
|
16
|
-
method_attrs = methods_index.fetch(op.method['system_name'])
|
17
|
-
method = Entities::Method.new(
|
18
|
-
id: method_attrs.fetch('id'),
|
19
|
-
parent_id: hits_metric_id,
|
20
|
-
service: service
|
21
|
-
)
|
15
|
+
method_attrs = methods_index.fetch(op.method['system_name']).attrs
|
16
|
+
method = Entities::Method.new(id: method_attrs.fetch('id'), service: service)
|
22
17
|
method.update(op.method)
|
23
18
|
op.set(:metric_id, method.id)
|
24
19
|
end
|
@@ -26,13 +21,9 @@ module ThreeScaleToolbox
|
|
26
21
|
|
27
22
|
private
|
28
23
|
|
29
|
-
def hits_metric_id
|
30
|
-
@hits_metric_id ||= service.hits['id']
|
31
|
-
end
|
32
|
-
|
33
24
|
def methods_index
|
34
|
-
@methods_index ||= service.methods
|
35
|
-
acc[method
|
25
|
+
@methods_index ||= service.methods.each_with_object({}) do |method, acc|
|
26
|
+
acc[method.system_name] = method
|
36
27
|
end
|
37
28
|
end
|
38
29
|
|
@@ -52,6 +52,7 @@ module ThreeScaleToolbox
|
|
52
52
|
case (type = api_spec.security[:type])
|
53
53
|
when 'oauth2'
|
54
54
|
settings[:credentials_location] = 'headers'
|
55
|
+
settings[:oidc_issuer_type] = oidc_issuer_type unless oidc_issuer_type.nil?
|
55
56
|
settings[:oidc_issuer_endpoint] = oidc_issuer_endpoint unless oidc_issuer_endpoint.nil?
|
56
57
|
when 'apiKey'
|
57
58
|
settings[:credentials_location] = credentials_location
|
@@ -47,11 +47,9 @@ module ThreeScaleToolbox
|
|
47
47
|
def run
|
48
48
|
validate_option_params
|
49
49
|
hits = service.hits
|
50
|
-
method = Entities::Method.find(service: service,
|
51
|
-
ref: method_ref)
|
50
|
+
method = Entities::Method.find(service: service, ref: method_ref)
|
52
51
|
if method.nil?
|
53
|
-
method = Entities::Method.create(service: service,
|
54
|
-
attrs: create_method_attrs)
|
52
|
+
method = Entities::Method.create(service: service, attrs: create_method_attrs)
|
55
53
|
else
|
56
54
|
method.update(method_attrs) unless method_attrs.empty?
|
57
55
|
end
|
@@ -44,7 +44,7 @@ module ThreeScaleToolbox
|
|
44
44
|
|
45
45
|
def find_method
|
46
46
|
hits = service.hits
|
47
|
-
Entities::Method.find(service: service,
|
47
|
+
Entities::Method.find(service: service, ref: method_ref).tap do |p|
|
48
48
|
raise ThreeScaleToolbox::Error, "Method #{method_ref} does not exist" if p.nil?
|
49
49
|
end
|
50
50
|
end
|
@@ -23,19 +23,11 @@ module ThreeScaleToolbox
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def run
|
26
|
-
printer.print_collection
|
26
|
+
printer.print_collection service.methods.map(&:attrs)
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def service_methods
|
32
|
-
@service_methods ||= service.methods service_hits_id
|
33
|
-
end
|
34
|
-
|
35
|
-
def service_hits_id
|
36
|
-
@service_hits_id ||= service.hits.fetch('id')
|
37
|
-
end
|
38
|
-
|
39
31
|
def service
|
40
32
|
@service ||= find_service
|
41
33
|
end
|
@@ -9,7 +9,7 @@ module ThreeScaleToolbox
|
|
9
9
|
# add metric system_name out of metric_id
|
10
10
|
def call
|
11
11
|
result[:limits] = plan.limits.map do |limit|
|
12
|
-
limit.
|
12
|
+
limit.attrs.merge('metric' => metric_info(limit, 'Limit'))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -21,7 +21,7 @@ module ThreeScaleToolbox
|
|
21
21
|
filtered_limit_methods.each_with_object({}) do |elem, acc|
|
22
22
|
# find_method should not return nil.
|
23
23
|
# It is assumed that metric_id refers to existing element from previous steps
|
24
|
-
acc[elem['metric_id']] = find_method(elem['metric_id'])
|
24
|
+
acc[elem['metric_id']] = find_method(elem['metric_id']).attrs
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -33,7 +33,7 @@ module ThreeScaleToolbox
|
|
33
33
|
filtered_pricing_rule_methods.each_with_object({}) do |elem, acc|
|
34
34
|
# find_method should not return nil.
|
35
35
|
# It is assumed that metric_id refers to existing element from previous steps
|
36
|
-
acc[elem['metric_id']] = find_method(elem['metric_id'])
|
36
|
+
acc[elem['metric_id']] = find_method(elem['metric_id']).attrs
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -21,7 +21,7 @@ module ThreeScaleToolbox
|
|
21
21
|
filtered_limit_metrics.each_with_object({}) do |elem, acc|
|
22
22
|
# find_metric should not return nil.
|
23
23
|
# It is assumed that metric_id refers to existing element from previous steps
|
24
|
-
acc[elem['metric_id']] = find_metric(elem['metric_id'])
|
24
|
+
acc[elem['metric_id']] = find_metric(elem['metric_id']).attrs
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -33,7 +33,7 @@ module ThreeScaleToolbox
|
|
33
33
|
filtered_pricing_rule_metrics.each_with_object({}) do |elem, acc|
|
34
34
|
# find_metric should not return nil.
|
35
35
|
# It is assumed that metric_id refers to existing element from previous steps
|
36
|
-
acc[elem['metric_id']] = find_metric(elem['metric_id'])
|
36
|
+
acc[elem['metric_id']] = find_metric(elem['metric_id']).attrs
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -9,8 +9,7 @@ module ThreeScaleToolbox
|
|
9
9
|
# add metric system_name out of metric_id
|
10
10
|
def call
|
11
11
|
result[:pricingrules] = plan.pricing_rules.map do |pr|
|
12
|
-
pr.merge('metric' => metric_info(pr, 'PricingRule'),
|
13
|
-
'cost_per_unit' => pr.fetch('cost_per_unit').to_f)
|
12
|
+
pr.attrs.merge('metric' => metric_info(pr, 'PricingRule'), 'cost_per_unit' => pr.cost_per_unit.to_f)
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
@@ -45,22 +45,14 @@ module ThreeScaleToolbox
|
|
45
45
|
context[:plan] ||= find_plan
|
46
46
|
end
|
47
47
|
|
48
|
-
def service_metrics
|
49
|
-
context[:service_metrics] ||= service.metrics
|
50
|
-
end
|
51
|
-
|
52
|
-
def service_methods
|
53
|
-
context[:service_methods] ||= service.methods(service_hits['id'])
|
54
|
-
end
|
55
|
-
|
56
48
|
def metric_info(elem, elem_name)
|
57
|
-
if (method = find_method(elem.
|
58
|
-
{ 'type' => 'method', 'system_name' => method.
|
59
|
-
elsif (metric = find_metric(elem.
|
60
|
-
{ 'type' => 'metric', 'system_name' => metric.
|
49
|
+
if (method = find_method(elem.metric_id))
|
50
|
+
{ 'type' => 'method', 'system_name' => method.system_name }
|
51
|
+
elsif (metric = find_metric(elem.metric_id))
|
52
|
+
{ 'type' => 'metric', 'system_name' => metric.system_name }
|
61
53
|
else
|
62
|
-
raise ThreeScaleToolbox::Error, "Unexpected error. #{elem_name} #{elem
|
63
|
-
"referencing to metric id #{elem.
|
54
|
+
raise ThreeScaleToolbox::Error, "Unexpected error. #{elem_name} #{elem.id} " \
|
55
|
+
"referencing to metric id #{elem.metric_id} which has not been found"
|
64
56
|
end
|
65
57
|
end
|
66
58
|
|
@@ -80,15 +72,11 @@ module ThreeScaleToolbox
|
|
80
72
|
end
|
81
73
|
|
82
74
|
def find_metric(id)
|
83
|
-
|
75
|
+
service.metrics.find { |metric| metric.id == id }
|
84
76
|
end
|
85
77
|
|
86
78
|
def find_method(id)
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
def service_hits
|
91
|
-
context[:service_hits] ||= service.hits
|
79
|
+
service.methods.find { |method| method.id == id }
|
92
80
|
end
|
93
81
|
end
|
94
82
|
end
|
@@ -7,31 +7,29 @@ module ThreeScaleToolbox
|
|
7
7
|
##
|
8
8
|
# Writes Plan limits
|
9
9
|
def call
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
# SET semantics
|
11
|
+
# First, delete existing limits
|
12
|
+
# Second, add new limits
|
13
|
+
plan.limits.each do |limit|
|
14
|
+
limit.delete()
|
15
|
+
puts "Deleted existing plan limit: [metric: #{limit.metric_id}, #{limit.attrs}]"
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
+
resource_limits_processed.each do |limit_attrs|
|
19
|
+
metric_id = limit_attrs.delete('metric_id')
|
20
|
+
plan.create_limit(metric_id, limit_attrs)
|
21
|
+
puts "Created plan limit: [metric: #{metric_id}, #{limit_attrs}]"
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
25
|
private
|
22
26
|
|
23
|
-
def missing_limits
|
24
|
-
ThreeScaleToolbox::Helper.array_difference(resource_limits_processed, plan.limits) do |a, b|
|
25
|
-
ThreeScaleToolbox::Helper.compare_hashes(a, b, %w[metric_id period])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
27
|
def resource_limits_processed
|
30
28
|
resource_limits.map do |limit|
|
31
29
|
metric = find_metric_by_system_name(limit.delete('metric_system_name'))
|
32
30
|
# this ImportMetricLimitsStep step is assuming all metrics/methods have been created
|
33
31
|
# in previous step, so finding metric should always succeed.
|
34
|
-
limit.merge('metric_id' => metric.
|
32
|
+
limit.merge('metric_id' => metric.id)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
@@ -9,36 +9,29 @@ module ThreeScaleToolbox
|
|
9
9
|
def call
|
10
10
|
missing_metrics.each(&method(:create_metric))
|
11
11
|
missing_methods.each(&method(:create_method))
|
12
|
-
|
13
|
-
# invalidate memoized methods and metrics
|
14
|
-
invalidate_service_methods
|
15
|
-
invalidate_service_metrics
|
16
12
|
end
|
17
13
|
|
18
14
|
private
|
19
15
|
|
20
16
|
def missing_metrics
|
21
|
-
ThreeScaleToolbox::Helper.array_difference(resource_metrics,
|
22
|
-
|
17
|
+
ThreeScaleToolbox::Helper.array_difference(resource_metrics, service.metrics) do |a, b|
|
18
|
+
a['system_name'] == b.system_name
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
26
22
|
def missing_methods
|
27
|
-
ThreeScaleToolbox::Helper.array_difference(resource_methods,
|
28
|
-
|
23
|
+
ThreeScaleToolbox::Helper.array_difference(resource_methods, service.methods) do |a, b|
|
24
|
+
a['system_name'] == b.system_name
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
28
|
def create_metric(metric_attrs)
|
33
|
-
metric = ThreeScaleToolbox::Entities::Metric.create(service: service,
|
34
|
-
attrs: metric_attrs)
|
29
|
+
metric = ThreeScaleToolbox::Entities::Metric.create(service: service, attrs: metric_attrs)
|
35
30
|
puts "Created metric: #{metric.attrs['system_name']}"
|
36
31
|
end
|
37
32
|
|
38
33
|
def create_method(method_attrs)
|
39
|
-
method = ThreeScaleToolbox::Entities::Method.create(service: service,
|
40
|
-
parent_id: service_hits['id'],
|
41
|
-
attrs: method_attrs)
|
34
|
+
method = ThreeScaleToolbox::Entities::Method.create(service: service, attrs: method_attrs)
|
42
35
|
puts "Created method: #{method.attrs['system_name']}"
|
43
36
|
end
|
44
37
|
end
|
@@ -7,35 +7,27 @@ module ThreeScaleToolbox
|
|
7
7
|
##
|
8
8
|
# Writes Plan pricing rules
|
9
9
|
def call
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
puts "Created plan pricing rule: [metric: #{metric_id}, #{pr}]"
|
10
|
+
# SET semantics
|
11
|
+
# First, delete existing pricing rules
|
12
|
+
# Second, add new pricing rules
|
13
|
+
plan.pricing_rules.each do |pr|
|
14
|
+
pr.delete()
|
15
|
+
puts "Deleted existing plan pricing rule: [metric: #{pr.metric_id}, #{pr.attrs}]"
|
18
16
|
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
17
|
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
resource_pr_processed.each do |pr_attrs|
|
19
|
+
metric_id = pr_attrs.delete('metric_id')
|
20
|
+
plan.create_pricing_rule(metric_id, pr_attrs)
|
21
|
+
puts "Created plan pricing rule: [metric: #{metric_id}, #{pr_attrs}]"
|
26
22
|
end
|
27
23
|
end
|
28
24
|
|
29
|
-
|
30
|
-
plan.pricing_rules.map do |pr|
|
31
|
-
pr.merge('cost_per_unit' => pr.fetch('cost_per_unit').to_f)
|
32
|
-
end
|
33
|
-
end
|
25
|
+
private
|
34
26
|
|
35
27
|
def resource_pr_processed
|
36
28
|
resource_pricing_rules.map do |pr|
|
37
29
|
metric = find_metric_by_system_name(pr.delete('metric_system_name'))
|
38
|
-
pr.merge('metric_id' => metric.
|
30
|
+
pr.merge('metric_id' => metric.id,
|
39
31
|
'cost_per_unit' => pr.fetch('cost_per_unit').to_f)
|
40
32
|
end
|
41
33
|
end
|
@@ -65,28 +65,8 @@ module ThreeScaleToolbox
|
|
65
65
|
artifacts_resource['plan_features'] || []
|
66
66
|
end
|
67
67
|
|
68
|
-
def service_metrics
|
69
|
-
context[:service_metrics] ||= service.metrics
|
70
|
-
end
|
71
|
-
|
72
|
-
def invalidate_service_metrics
|
73
|
-
context[:service_metrics] = nil
|
74
|
-
end
|
75
|
-
|
76
|
-
def service_hits
|
77
|
-
context[:service_hits] ||= service.hits
|
78
|
-
end
|
79
|
-
|
80
|
-
def service_methods
|
81
|
-
context[:service_methods] ||= service.methods(service_hits['id'])
|
82
|
-
end
|
83
|
-
|
84
68
|
def service_metrics_and_methods
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
def invalidate_service_methods
|
89
|
-
context[:service_methods] = nil
|
69
|
+
service.metrics + service.methods
|
90
70
|
end
|
91
71
|
|
92
72
|
def service_features
|
@@ -103,7 +83,7 @@ module ThreeScaleToolbox
|
|
103
83
|
end
|
104
84
|
|
105
85
|
def find_metric_by_system_name(system_name)
|
106
|
-
service_metrics_and_methods.find { |metric| metric
|
86
|
+
service_metrics_and_methods.find { |metric| metric.system_name == system_name }
|
107
87
|
end
|
108
88
|
|
109
89
|
private
|
@@ -5,7 +5,7 @@ module ThreeScaleToolbox
|
|
5
5
|
class ShowSubcommand < Cri::CommandRunner
|
6
6
|
include ThreeScaleToolbox::Command
|
7
7
|
|
8
|
-
FIELDS_TO_SHOW = %w[id name system_name approval_required
|
8
|
+
FIELDS_TO_SHOW = %w[id name system_name approval_required
|
9
9
|
cost_per_month setup_fee trial_period_days].freeze
|
10
10
|
|
11
11
|
def self.command
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require '3scale_toolbox/commands/policies_command/export_command'
|
2
|
+
require '3scale_toolbox/commands/policies_command/import_command'
|
3
|
+
|
4
|
+
module ThreeScaleToolbox
|
5
|
+
module Commands
|
6
|
+
module PoliciesCommand
|
7
|
+
include ThreeScaleToolbox::Command
|
8
|
+
def self.command
|
9
|
+
Cri::Command.define do
|
10
|
+
name 'policies'
|
11
|
+
usage 'policies <sub-command> [options]'
|
12
|
+
summary 'policies super command'
|
13
|
+
description 'Policies commands'
|
14
|
+
|
15
|
+
run do |_opts, _args, cmd|
|
16
|
+
puts cmd.help
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
add_subcommand(ExportSubcommand)
|
21
|
+
add_subcommand(ImportSubcommand)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|