3scale_toolbox 0.17.1 → 0.19.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 +4 -4
- data/README.md +7 -5
- data/lib/3scale_toolbox.rb +3 -0
- data/lib/3scale_toolbox/3scale_client_factory.rb +3 -4
- data/lib/3scale_toolbox/commands.rb +2 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command.rb +3 -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/delete_mapping_rules_task.rb +18 -0
- data/lib/3scale_toolbox/commands/backend_command/copy_command/task.rb +14 -32
- data/lib/3scale_toolbox/commands/import_command/issuer_type_transformer.rb +16 -0
- data/lib/3scale_toolbox/commands/import_command/openapi.rb +5 -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 +7 -8
- 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 +8 -15
- 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 +8 -3
- data/lib/3scale_toolbox/commands/product_command/copy_command/copy_backends_task.rb +28 -5
- data/lib/3scale_toolbox/commands/product_command/export_command.rb +81 -0
- data/lib/3scale_toolbox/commands/product_command/import_command.rb +126 -0
- data/lib/3scale_toolbox/commands/proxy_config_command.rb +2 -0
- data/lib/3scale_toolbox/commands/proxy_config_command/deploy_command.rb +54 -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 +2 -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/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/account.rb +1 -1
- data/lib/3scale_toolbox/entities/activedocs.rb +12 -0
- data/lib/3scale_toolbox/entities/application_plan.rb +54 -46
- 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/helper.rb +13 -16
- data/lib/3scale_toolbox/proxy_logger.rb +4 -0
- data/lib/3scale_toolbox/remote_cache.rb +164 -0
- data/lib/3scale_toolbox/remotes.rb +2 -2
- data/lib/3scale_toolbox/version.rb +1 -1
- data/licenses.xml +98 -50
- metadata +37 -9
@@ -0,0 +1,16 @@
|
|
1
|
+
require '3scale_toolbox/crds/application_plan_dump'
|
2
|
+
require '3scale_toolbox/crds/backend_method_dump'
|
3
|
+
require '3scale_toolbox/crds/backend_mapping_rule_dump'
|
4
|
+
require '3scale_toolbox/crds/backend_metric_dump'
|
5
|
+
require '3scale_toolbox/crds/backend_dump'
|
6
|
+
require '3scale_toolbox/crds/backend_usage_dump'
|
7
|
+
require '3scale_toolbox/crds/limit_dump'
|
8
|
+
require '3scale_toolbox/crds/mapping_rule_dump'
|
9
|
+
require '3scale_toolbox/crds/method_dump'
|
10
|
+
require '3scale_toolbox/crds/metric_dump'
|
11
|
+
require '3scale_toolbox/crds/pricing_rule_dump'
|
12
|
+
require '3scale_toolbox/crds/product_dump'
|
13
|
+
require '3scale_toolbox/crds/product_deployment_parser'
|
14
|
+
require '3scale_toolbox/crds/backend_parser'
|
15
|
+
require '3scale_toolbox/crds/product_parser'
|
16
|
+
require '3scale_toolbox/crds/remote'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module CRD
|
3
|
+
module ApplicationPlanSerializer
|
4
|
+
def to_cr
|
5
|
+
{
|
6
|
+
'name' => name,
|
7
|
+
'appsRequireApproval' => approval_required?,
|
8
|
+
'trialPeriod' => trial_period_days,
|
9
|
+
'setupFee' => setup_fee,
|
10
|
+
'custom' => custom,
|
11
|
+
'state' => state,
|
12
|
+
'costMonth' => cost_per_month,
|
13
|
+
'pricingRules' => pricing_rules.map(&:to_cr),
|
14
|
+
'limits' => limits.map(&:to_cr)
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module CRD
|
3
|
+
module BackendSerializer
|
4
|
+
def to_cr
|
5
|
+
{
|
6
|
+
'apiVersion' => 'capabilities.3scale.net/v1beta1',
|
7
|
+
'kind' => 'Backend',
|
8
|
+
'metadata' => {
|
9
|
+
'annotations' => {
|
10
|
+
'3scale_toolbox_created_at' => Time.now.utc.iso8601,
|
11
|
+
'3scale_toolbox_version' => ThreeScaleToolbox::VERSION
|
12
|
+
},
|
13
|
+
'name' => cr_name
|
14
|
+
},
|
15
|
+
'spec' => {
|
16
|
+
'name' => name,
|
17
|
+
'systemName' => system_name,
|
18
|
+
'privateBaseURL' => private_endpoint,
|
19
|
+
'description' => description,
|
20
|
+
'mappingRules' => mapping_rules.map(&:to_cr),
|
21
|
+
'metrics' => metrics.each_with_object({}) do |metric, hash|
|
22
|
+
hash[metric.system_name] = metric.to_cr
|
23
|
+
end,
|
24
|
+
'methods' => methods.each_with_object({}) do |method, hash|
|
25
|
+
hash[method.system_name] = method.to_cr
|
26
|
+
end
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def cr_name
|
32
|
+
# Should be DNS1123 subdomain name
|
33
|
+
# TODO run validation for DNS1123
|
34
|
+
# https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
|
35
|
+
"#{system_name.gsub(/[^[a-zA-Z0-9\-\.]]/, '.')}.#{Helper.random_lowercase_name}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module CRD
|
3
|
+
module BackendMappingRuleSerializer
|
4
|
+
def to_cr
|
5
|
+
{
|
6
|
+
'httpMethod' => http_method,
|
7
|
+
'pattern' => pattern,
|
8
|
+
'metricMethodRef' => metric_method_ref,
|
9
|
+
'increment' => delta,
|
10
|
+
'last' => last,
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def metric_method_ref
|
15
|
+
if (method = backend.methods.find { |m| m.id == metric_id })
|
16
|
+
method.system_name
|
17
|
+
elsif (metric = backend.metrics.find { |m| m.id == metric_id })
|
18
|
+
metric.system_name
|
19
|
+
else
|
20
|
+
raise ThreeScaleToolbox::Error, "Unexpected error. Backend #{backend.system_name} " \
|
21
|
+
"mapping rule #{id} referencing to metric id #{metric_id} which has not been found"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module CRD
|
3
|
+
class BackendParser
|
4
|
+
Metric = Struct.new(:system_name, :friendly_name, :description, :unit)
|
5
|
+
Method = Struct.new(:system_name, :friendly_name, :description)
|
6
|
+
MappingRule = Struct.new(:metric_ref, :http_method, :pattern, :delta, :last)
|
7
|
+
|
8
|
+
attr_reader :cr
|
9
|
+
|
10
|
+
def initialize(cr)
|
11
|
+
@cr = cr
|
12
|
+
end
|
13
|
+
|
14
|
+
def system_name
|
15
|
+
cr.dig('spec', 'systemName')
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
cr.dig('spec', 'name')
|
20
|
+
end
|
21
|
+
|
22
|
+
def description
|
23
|
+
cr.dig('spec', 'description')
|
24
|
+
end
|
25
|
+
|
26
|
+
def private_endpoint
|
27
|
+
cr.dig('spec', 'privateBaseURL')
|
28
|
+
end
|
29
|
+
|
30
|
+
def metrics
|
31
|
+
@metrics ||= (cr.dig('spec', 'metrics') || {}).map do |system_name, metric|
|
32
|
+
Metric.new(system_name, metric['friendlyName'], metric['description'], metric['unit'])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def methods
|
37
|
+
@methods ||= (cr.dig('spec', 'methods') || {}).map do |system_name, method|
|
38
|
+
Method.new(system_name, method['friendlyName'], method['description'])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def mapping_rules
|
43
|
+
@mapping_rules ||= (cr.dig('spec', 'mappingRules') || []).map do |mapping_rule|
|
44
|
+
MappingRule.new(mapping_rule['metricMethodRef'], mapping_rule['httpMethod'],
|
45
|
+
mapping_rule['pattern'], mapping_rule['increment'], mapping_rule['last'])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Metrics and methods index by system_name
|
50
|
+
def metrics_index
|
51
|
+
@metrics_index ||= (methods + metrics).each_with_object({}) { |metric, h| h[metric.system_name] = metric }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module CRD
|
3
|
+
module Limit
|
4
|
+
def to_cr
|
5
|
+
{
|
6
|
+
'period' => period,
|
7
|
+
'value' => value,
|
8
|
+
'metricMethodRef' => metric_system_name,
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def metric_system_name
|
13
|
+
# Find in service methods
|
14
|
+
# Find in service metrics
|
15
|
+
# Find in backend methods
|
16
|
+
# Find in backend metrics
|
17
|
+
if (method = plan.service.methods.find { |m| m.id == metric_id })
|
18
|
+
{ 'systemName' => method.system_name }
|
19
|
+
elsif (metric = plan.service.metrics.find { |m| m.id == metric_id })
|
20
|
+
{ 'systemName' => metric.system_name }
|
21
|
+
elsif (backend = backend_from_metric)
|
22
|
+
if (backend_metric = backend.metrics.find { |m| m.id == metric_id })
|
23
|
+
{ 'systemName' => backend_metric.system_name, 'backend' => backend.system_name }
|
24
|
+
elsif (backend_method = backend.methods.find { |m| m.id == metric_id })
|
25
|
+
{ 'systemName' => backend_method.system_name, 'backend' => backend.system_name }
|
26
|
+
else
|
27
|
+
raise ThreeScaleToolbox::Error, "Unexpected error. Limit #{id} " \
|
28
|
+
"referencing to metric id #{metric_id} which has not been found"
|
29
|
+
end
|
30
|
+
else
|
31
|
+
raise ThreeScaleToolbox::Error, "Unexpected error. Limit #{id} " \
|
32
|
+
"referencing to metric id #{metric_id} which has not been found"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module CRD
|
3
|
+
module MappingRuleSerializer
|
4
|
+
def to_cr
|
5
|
+
{
|
6
|
+
'httpMethod' => http_method,
|
7
|
+
'pattern' => pattern,
|
8
|
+
'metricMethodRef' => metric_method_ref,
|
9
|
+
'increment' => delta,
|
10
|
+
'last' => last,
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def metric_method_ref
|
15
|
+
if (method = service.methods.find { |m| m.id == metric_id })
|
16
|
+
method.system_name
|
17
|
+
elsif (metric = service.metrics.find { |m| m.id == metric_id })
|
18
|
+
metric.system_name
|
19
|
+
else
|
20
|
+
raise ThreeScaleToolbox::Error, "Unexpected error. Service #{service.system_name} " \
|
21
|
+
"mapping rule #{id} referencing to metric id #{metric_id} which has not been found"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module CRD
|
3
|
+
module PricingRuleSerializer
|
4
|
+
def to_cr
|
5
|
+
{
|
6
|
+
'from' => min,
|
7
|
+
'to' => max,
|
8
|
+
'pricePerUnit' => cost_per_unit,
|
9
|
+
'metricMethodRef' => metric_system_name,
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def metric_system_name
|
14
|
+
# Find in service methods
|
15
|
+
# Find in service metrics
|
16
|
+
# Find in backend methods
|
17
|
+
# Find in backend metrics
|
18
|
+
if (method = plan.service.methods.find { |m| m.id == metric_id })
|
19
|
+
{ 'systemName' => method.system_name }
|
20
|
+
elsif (metric = plan.service.metrics.find { |m| m.id == metric_id })
|
21
|
+
{ 'systemName' => metric.system_name }
|
22
|
+
elsif (backend = backend_from_metric)
|
23
|
+
if (backend_metric = backend.metrics.find { |m| m.id == metric_id })
|
24
|
+
{ 'systemName' => backend_metric.system_name, 'backend' => backend.system_name }
|
25
|
+
elsif (backend_method = backend.methods.find { |m| m.id == metric_id })
|
26
|
+
{ 'systemName' => backend_method.system_name, 'backend' => backend.system_name }
|
27
|
+
else
|
28
|
+
raise ThreeScaleToolbox::Error, "Unexpected error. PricingRule #{id} " \
|
29
|
+
"referencing to metric id #{metric_id} which has not been found"
|
30
|
+
end
|
31
|
+
else
|
32
|
+
raise ThreeScaleToolbox::Error, "Unexpected error. PricingRule #{id} " \
|
33
|
+
"referencing to metric id #{metric_id} which has not been found"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,329 @@
|
|
1
|
+
module ThreeScaleToolbox
|
2
|
+
module CRD
|
3
|
+
# ProductDeploymentCRDParser parses CRD Format
|
4
|
+
# https://github.com/3scale/3scale-operator/blob/3scale-2.10.0-CR2/doc/product-reference.md#productdeploymentspec
|
5
|
+
class ProductDeploymentParser
|
6
|
+
class ApicastHostedParser
|
7
|
+
attr_reader :authentication_parser
|
8
|
+
|
9
|
+
def initialize(cr)
|
10
|
+
@authentication_parser = AuthenticationParser.new(cr.fetch('authentication', {}))
|
11
|
+
end
|
12
|
+
|
13
|
+
def deployment_option
|
14
|
+
'hosted'
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing(name, *args)
|
18
|
+
authentication_parser.public_send(name, *args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def respond_to_missing?(method_name, include_private = false)
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class ApicastSelfManagedParser
|
27
|
+
attr_reader :authentication_parser, :cr
|
28
|
+
|
29
|
+
def initialize(cr)
|
30
|
+
@cr = cr
|
31
|
+
@authentication_parser = AuthenticationParser.new(cr.fetch('authentication', {}))
|
32
|
+
end
|
33
|
+
|
34
|
+
def deployment_option
|
35
|
+
'self_managed'
|
36
|
+
end
|
37
|
+
|
38
|
+
def endpoint
|
39
|
+
cr['productionPublicBaseURL']
|
40
|
+
end
|
41
|
+
|
42
|
+
def sandbox_endpoint
|
43
|
+
cr['stagingPublicBaseURL']
|
44
|
+
end
|
45
|
+
|
46
|
+
def method_missing(name, *args)
|
47
|
+
authentication_parser.public_send(name, *args)
|
48
|
+
end
|
49
|
+
|
50
|
+
def respond_to_missing?(method_name, include_private = false)
|
51
|
+
super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class AuthenticationParser
|
56
|
+
attr_reader :parser
|
57
|
+
|
58
|
+
def initialize(cr)
|
59
|
+
@parser = if cr.has_key? 'userkey'
|
60
|
+
UserKeyParser.new(cr.fetch('userkey'))
|
61
|
+
elsif cr.has_key? 'appKeyAppID'
|
62
|
+
AppKeyParser.new(cr.fetch('appKeyAppID'))
|
63
|
+
elsif cr.has_key? 'oidc'
|
64
|
+
OidcParser.new(cr.fetch('oidc'))
|
65
|
+
else
|
66
|
+
raise ThreeScaleToolbox::Error, "Unknown authentication option: #{cr.keys}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def method_missing(name, *args)
|
72
|
+
parser.public_send(name, *args)
|
73
|
+
end
|
74
|
+
|
75
|
+
def respond_to_missing?(method_name, include_private = false)
|
76
|
+
super
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class AppKeyParser
|
81
|
+
|
82
|
+
attr_reader :cr, :security_parser, :gaterway_response_parser
|
83
|
+
|
84
|
+
def initialize(cr)
|
85
|
+
@cr = cr
|
86
|
+
@security_parser = SecurityParser.new(cr.fetch('security', {}))
|
87
|
+
@gaterway_response_parser = GatewayResponseParser.new(cr.fetch('gatewayResponse', {}))
|
88
|
+
end
|
89
|
+
|
90
|
+
def auth_app_id
|
91
|
+
cr['appID']
|
92
|
+
end
|
93
|
+
|
94
|
+
def auth_app_key
|
95
|
+
cr['appKey']
|
96
|
+
end
|
97
|
+
|
98
|
+
def credentials_location
|
99
|
+
cr['credentials']
|
100
|
+
end
|
101
|
+
|
102
|
+
def backend_version
|
103
|
+
'2'
|
104
|
+
end
|
105
|
+
|
106
|
+
def method_missing(name, *args)
|
107
|
+
res = security_parser.public_send(name, *args)
|
108
|
+
return res unless res.nil?
|
109
|
+
|
110
|
+
gaterway_response_parser.public_send(name, *args)
|
111
|
+
end
|
112
|
+
|
113
|
+
def respond_to_missing?(method_name, include_private = false)
|
114
|
+
super
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class UserKeyParser
|
119
|
+
attr_reader :cr, :security_parser, :gaterway_response_parser
|
120
|
+
|
121
|
+
def initialize(cr)
|
122
|
+
@cr = cr
|
123
|
+
@security_parser = SecurityParser.new(cr.fetch('security', {}))
|
124
|
+
@gaterway_response_parser = GatewayResponseParser.new(cr.fetch('gatewayResponse', {}))
|
125
|
+
end
|
126
|
+
|
127
|
+
def backend_version
|
128
|
+
'1'
|
129
|
+
end
|
130
|
+
|
131
|
+
def auth_user_key
|
132
|
+
cr['authUserKey']
|
133
|
+
end
|
134
|
+
|
135
|
+
def credentials_location
|
136
|
+
cr['credentials']
|
137
|
+
end
|
138
|
+
|
139
|
+
def method_missing(name, *args)
|
140
|
+
res = security_parser.public_send(name, *args)
|
141
|
+
return res unless res.nil?
|
142
|
+
|
143
|
+
gaterway_response_parser.public_send(name, *args)
|
144
|
+
end
|
145
|
+
|
146
|
+
def respond_to_missing?(method_name, include_private = false)
|
147
|
+
super
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
class OidcParser
|
152
|
+
attr_reader :cr, :security_parser, :gaterway_response_parser, :authentication_flow_parser
|
153
|
+
|
154
|
+
def initialize(cr)
|
155
|
+
@cr = cr
|
156
|
+
@security_parser = SecurityParser.new(cr.fetch('security', {}))
|
157
|
+
@gaterway_response_parser = GatewayResponseParser.new(cr.fetch('gatewayResponse', {}))
|
158
|
+
@authentication_flow_parser = AuthenticationFlowParser.new(cr.fetch('authenticationFlow', {}))
|
159
|
+
end
|
160
|
+
|
161
|
+
def backend_version
|
162
|
+
'oidc'
|
163
|
+
end
|
164
|
+
|
165
|
+
def credentials_location
|
166
|
+
cr['credentials']
|
167
|
+
end
|
168
|
+
|
169
|
+
def oidc_issuer_endpoint
|
170
|
+
cr['issuerEndpoint']
|
171
|
+
end
|
172
|
+
|
173
|
+
def oidc_issuer_type
|
174
|
+
cr['issuerType']
|
175
|
+
end
|
176
|
+
|
177
|
+
def jwt_claim_with_client_id
|
178
|
+
cr['jwtClaimWithClientID']
|
179
|
+
end
|
180
|
+
|
181
|
+
def jwt_claim_with_client_id_type
|
182
|
+
cr['jwtClaimWithClientIDType']
|
183
|
+
end
|
184
|
+
|
185
|
+
def method_missing(name, *args)
|
186
|
+
res = authentication_flow_parser.public_send(name, *args)
|
187
|
+
return res unless res.nil?
|
188
|
+
|
189
|
+
res = security_parser.public_send(name, *args)
|
190
|
+
return res unless res.nil?
|
191
|
+
|
192
|
+
gaterway_response_parser.public_send(name, *args)
|
193
|
+
end
|
194
|
+
|
195
|
+
def respond_to_missing?(method_name, include_private = false)
|
196
|
+
super
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
class SecurityParser
|
201
|
+
attr_reader :cr
|
202
|
+
|
203
|
+
def initialize(cr)
|
204
|
+
@cr = cr
|
205
|
+
end
|
206
|
+
|
207
|
+
def secret_token
|
208
|
+
cr['secretToken']
|
209
|
+
end
|
210
|
+
|
211
|
+
def hostname_rewrite
|
212
|
+
cr['hostHeader']
|
213
|
+
end
|
214
|
+
|
215
|
+
def method_missing(name, *args)
|
216
|
+
nil
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
class GatewayResponseParser
|
221
|
+
attr_reader :cr
|
222
|
+
|
223
|
+
def initialize(cr)
|
224
|
+
@cr = cr
|
225
|
+
end
|
226
|
+
|
227
|
+
def error_auth_failed
|
228
|
+
cr['errorAuthFailed']
|
229
|
+
end
|
230
|
+
|
231
|
+
def error_auth_missing
|
232
|
+
cr['errorAuthMissing']
|
233
|
+
end
|
234
|
+
|
235
|
+
def error_status_auth_failed
|
236
|
+
cr['errorStatusAuthFailed']
|
237
|
+
end
|
238
|
+
|
239
|
+
def error_headers_auth_failed
|
240
|
+
cr['errorHeadersAuthFailed']
|
241
|
+
end
|
242
|
+
|
243
|
+
def error_status_auth_missing
|
244
|
+
cr['errorStatusAuthMissing']
|
245
|
+
end
|
246
|
+
|
247
|
+
def error_headers_auth_missing
|
248
|
+
cr['errorHeadersAuthMissing']
|
249
|
+
end
|
250
|
+
|
251
|
+
def error_no_match
|
252
|
+
cr['errorNoMatch']
|
253
|
+
end
|
254
|
+
|
255
|
+
def error_status_no_match
|
256
|
+
cr['errorStatusNoMatch']
|
257
|
+
end
|
258
|
+
|
259
|
+
def error_headers_no_match
|
260
|
+
cr['errorHeadersNoMatch']
|
261
|
+
end
|
262
|
+
|
263
|
+
def error_limits_exceeded
|
264
|
+
cr['errorLimitsExceeded']
|
265
|
+
end
|
266
|
+
|
267
|
+
def error_status_limits_exceeded
|
268
|
+
cr['errorStatusLimitsExceeded']
|
269
|
+
end
|
270
|
+
|
271
|
+
def error_headers_limits_exceeded
|
272
|
+
cr['errorHeadersLimitsExceeded']
|
273
|
+
end
|
274
|
+
|
275
|
+
def method_missing(name, *args)
|
276
|
+
nil
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
class AuthenticationFlowParser
|
281
|
+
attr_reader :cr
|
282
|
+
|
283
|
+
def initialize(cr)
|
284
|
+
@cr = cr
|
285
|
+
end
|
286
|
+
|
287
|
+
def standard_flow_enabled
|
288
|
+
cr.fetch('standardFlowEnabled', false)
|
289
|
+
end
|
290
|
+
|
291
|
+
def implicit_flow_enabled
|
292
|
+
cr.fetch('implicitFlowEnabled', false)
|
293
|
+
end
|
294
|
+
|
295
|
+
def service_accounts_enabled
|
296
|
+
cr.fetch('serviceAccountsEnabled', false)
|
297
|
+
end
|
298
|
+
|
299
|
+
def direct_access_grants_enabled
|
300
|
+
cr.fetch('directAccessGrantsEnabled', false)
|
301
|
+
end
|
302
|
+
|
303
|
+
def method_missing(name, *args)
|
304
|
+
nil
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
attr_reader :deployment_parser
|
309
|
+
|
310
|
+
def initialize(cr)
|
311
|
+
@deployment_parser = if cr.has_key? 'apicastSelfManaged'
|
312
|
+
ApicastSelfManagedParser.new(cr.fetch('apicastSelfManaged'))
|
313
|
+
elsif cr.has_key? 'apicastHosted'
|
314
|
+
ApicastHostedParser.new(cr.fetch('apicastHosted'))
|
315
|
+
else
|
316
|
+
raise ThreeScaleToolbox::Error, "Unknown deployment option: #{cr.keys}"
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
def method_missing(name, *args)
|
321
|
+
deployment_parser.public_send(name, *args)
|
322
|
+
end
|
323
|
+
|
324
|
+
def respond_to_missing?(method_name, include_private = false)
|
325
|
+
super
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|