Sha256: 3541f307e317fd32ecbfc90d965f3c2fd36ce1514a964c389517d1e689719b69

Contents?: true

Size: 1.33 KB

Versions: 9

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module Aws
  module Endpoints
    # @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

9 entries across 9 versions & 1 rubygems

Version Path
aws-sdk-core-3.168.4 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.168.3 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.168.2 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.168.1 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.168.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.167.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.166.0 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.165.1 lib/aws-sdk-core/endpoints/rule_set.rb
aws-sdk-core-3.165.0 lib/aws-sdk-core/endpoints/rule_set.rb