Sha256: 7350d3db471cc6883b9f3017e56062e66ca899f0601d4de12440a06cbd3e7d97

Contents?: true

Size: 990 Bytes

Versions: 8

Compression:

Stored size: 990 Bytes

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
            # apply strict matching
            "#{raw_pattern}$"
          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

8 entries across 8 versions & 1 rubygems

Version Path
3scale_toolbox-0.14.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.13.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.12.4 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.12.3 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.12.2 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.11.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.10.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb
3scale_toolbox-0.9.0 lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb