Sha256: 4147164b31379cebac69a49756144b158a7b4a9eb03e7a2be8fdf3dd9fe7e42b

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require "azure/configuration"
require "uri"

module Azure
  module ServiceBus
    module Rules
      module URI
        # Public: Generate the URI for a given rule.
        #
        # topic_name        - String representing the name of the Topic.
        # subscription_name - String representing the name of the Subscription.
        # rule_name         - String representing the name of the new Rule.
        #
        # Returns a URI.
        def self.rule(topic_name, subscription_name, rule_name, host=Azure.config.service_bus_host)
          path = "#{topic_name}/subscriptions/#{subscription_name}/rules/#{rule_name}"
          generate(host, path)
        end

        # Public: Generate the URI for a collection of rules.
        #
        # topic_name        - String representing the name of the Topic.
        # subscription_name - String representing the name of the Subscription.
        #
        # Returns a URI.
        def self.collection(topic_name, subscription_name, host=Azure.config.service_bus_host)
          path = "#{topic_name}/subscriptions/#{subscription_name}/rules"
          generate(host, path)
        end

        def self.generate(host, path, query={})
          uri = ::URI.parse(File.join(host, path))
          uri.query = ::URI.encode_www_form(query) unless query.empty?
          uri
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 lib/azure/service_bus/rules/uri.rb
azure-0.1.0 lib/azure/service_bus/rules/uri.rb