<commit_before>require 'time'
require_relative 'model/base_model'

module Azure
  module Armrest
    # Abstract base class for the other service classes.
    class ArmrestService
      extend Gem::Deprecate

      # Configuration to access azure APIs
      attr_accessor :armrest_configuration

      alias configuration armrest_configuration

      # Base url used for REST calls.
      attr_accessor :base_url

      # Provider for service specific API calls
      attr_accessor :provider

      # The api-version string for this particular service
      attr_accessor :api_version

      # Returns a new Armrest::Configuration object.
      #
      # This method is deprecated, but is provided for backwards compatibility.
      #
      def self.configure(options)
        Azure::Armrest::Configuration.new(options)
      end

      # Do not instantiate directly. This is an abstract base class from which
      # all other service classes should subclass, and call super within their
      # own constructors.
      #
      def initialize(armrest_configuration, service_name, default_provider, options)
        @armrest_configuration = armrest_configuration
        @service_name = service_name
        @provider = options[:provider] || default_provider

        # Base URL used for REST calls. Modify within method calls as needed.
        @base_url = Azure::Armrest::RESOURCE

        set_service_api_version(options, service_name)
      end

      # Returns a list of the available resource providers. This is really
      # just a wrapper for Azure::Armrest::Configuration#providers.
      #
      delegate :providers, :to => :configuration, :prefix => :list

      alias providers list_providers
      deprecate :providers, :list_providers, 2018, 1

      # Returns information about the specific provider +namespace+.
      #
      def get_provider(provider)
        configuration.providers.find { |rp| rp.namespace.casecmp(provider) == 0 }
      end

      alias geo_locations get_provider
      alias provider_info get_provider
      deprecate :provider_info, :get_provider, 2018, 1

      # Returns a list of all locations for all resource types of the given
      # +provider+. If you do not specify a provider, then the locations for
      # all providers will be returned.
      #
      # If you need individual details on a per-provider basis, use the
      # provider_info method instead.
      #--
      #
      def locations(provider = nil)
        list = configuration.providers
        list = list.select { |rp| rp.namespace.casecmp(provider) == 0 } if provider

        list.collect { |rp| rp.resource_types.map(&:locations) }.flatten.uniq.sort
      end

      # Returns a list of Subscription objects for the tenant.
      #
      def list_subscriptions<commit_msg>Delegate the hash method, and create an 'as_cache_key' alias, for the cache_method library interface.<commit_after>require 'time'
require_relative 'model/base_model'

module Azure
  module Armrest
    # Abstract base class for the other service classes.
    class ArmrestService
      extend Gem::Deprecate

      # Configuration to access azure APIs
      attr_accessor :armrest_configuration

      alias configuration armrest_configuration

      # Base url used for REST calls.
      attr_accessor :base_url

      # Provider for service specific API calls
      attr_accessor :provider

      # The api-version string for this particular service
      attr_accessor :api_version

      # Returns a new Armrest::Configuration object.
      #
      # This method is deprecated, but is provided for backwards compatibility.
      #
      def self.configure(options)
        Azure::Armrest::Configuration.new(options)
      end

      # Do not instantiate directly. This is an abstract base class from which
      # all other service classes should subclass, and call super within their
      # own constructors.
      #
      def initialize(armrest_configuration, service_name, default_provider, options)
        @armrest_configuration = armrest_configuration
        @service_name = service_name
        @provider = options[:provider] || default_provider

        # Base URL used for REST calls. Modify within method calls as needed.
        @base_url = Azure::Armrest::RESOURCE

        set_service_api_version(options, service_name)
      end

      # Returns a list of the available resource providers. This is really
      # just a wrapper for Azure::Armrest::Configuration#providers.
      #
      delegate :providers, :to => :configuration, :prefix => :list

      alias providers list_providers
      deprecate :providers, :list_providers, 2018, 1

      # Need an "as_cache_key" method for the cache_method library interface.
      delegate :hash, :to => :configuration
      alias as_cache_key hash

      # Returns information about the specific provider +namespace+.
      #
      def get_provider(provider)
        configuration.providers.find { |rp| rp.namespace.casecmp(provider) == 0 }
      end

      alias geo_locations get_provider
      alias provider_info get_provider
      deprecate :provider_info, :get_provider, 2018, 1

      # Returns a list of all locations for all resource types of the given
      # +provider+. If you do not specify a provider, then the locations for
      # all providers will be returned.
      #
      # If you need individual details on a per-provider basis, use the
      # provider_info method instead.
      #--
      #
      def locations(provider = nil)
        list = configuration.providers
        list = list.select { |rp| rp.namespace.casecmp(provider) == 0 } if provider

        list.collect { |rp| rp.resource_types.map(&:locations) }.flatten.uniq.sort
      end

      # Returns a list of Subscription objects for the tenant.
      #
      def list_subscriptions
{'fraction_non_alphanumeric': 0.06373475347878371, 'fraction_numerical': 0.004123002920460402, 'mean_word_length': 2.8027433050293924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6421660', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1458, 'n_words': 538}