Sha256: 94a05ca31d710911a4ff4fefb2ee3c4a2968ecb0162216ce4cd3c05021468c4a

Contents?: true

Size: 1.62 KB

Versions: 77

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

module Aws
  module Endpoints
    # This class is deprecated. It is used by the Runtime endpoint
    # resolution approach. It has been replaced by a code generated
    # approach in each service gem. It can be removed in a new
    # major version. It has to exist because
    # old service gems can use a new core version.
    # @api private
    class RuleSet
      def initialize(version:, service_id:, parameters:, rules:)
        @version = version
        @service_id = service_id
        @parameters = parameters
        @rules = RuleSet.rules_from_json(rules || [])
      end

      attr_reader :version
      attr_reader :service_id
      attr_reader :parameters
      attr_reader :rules

      def self.rules_from_json(rules_json)
        rules_json.each.with_object([]) do |rule, rules|
          if rule['type'] == 'endpoint'
            rules << EndpointRule.new(
              conditions: rule['conditions'],
              endpoint: rule['endpoint'],
              documentation: rule['documentation']
            )
          elsif rule['type'] == 'error'
            rules << ErrorRule.new(
              conditions: rule['conditions'],
              error: rule['error'],
              documentation: rule['documentation']
            )
          elsif rule['type'] == 'tree'
            rules << TreeRule.new(
              conditions: rule['conditions'],
              rules: rule['rules'],
              documentation: rule['documentation']
            )
          else
            # should not happen
            raise "Unknown endpoint rule type: #{rule}"
          end
        end
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
aws-sdk-core-3.214.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.213.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.212.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.211.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.210.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.209.1 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.209.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.208.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.207.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.206.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.205.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.204.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.203.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.202.2 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.202.1 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.202.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.201.5 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.201.4 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.201.3 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.201.2 lib/aws-sdk-core/endpoints/rule_set.rb