Sha256: 386e64486b14beef5942204b11f47bce1fa0da956b1ba7f86ccc37884e18dbf8

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ImportCommand
      module OpenAPI
        module MappingRule
          def mapping_rule
            {
              'pattern' => pattern,
              'http_method' => http_method,
              'delta' => delta,
              'metric_id' => metric_id
            }
          end

          def http_method
            operation[:verb].upcase
          end

          def pattern
            res = "#{raw_pattern}"
            res = "#{res}$" if !operation[:prefix_matching] # apply strict matching
            res
          end

          def raw_pattern
            # According OAS 2.0: path MUST begin with a slash
            "#{public_base_path}#{operation[:path]}"
          end

          def public_base_path
            # remove the last slash of the basePath
            operation[:public_base_path].gsub(%r{/$}, '')
          end

          def delta
            1
          end

          def metric_id
            operation[:metric_id]
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
3scale_toolbox-1.0.1 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-1.0.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.20.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.19.3 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.19.2 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.19.1 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.19.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.18.3 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.18.2 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.18.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.17.1 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.15.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb