From b1064fe69abbf84a1439fcd7cd15754767085102 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 24 Oct 2017 23:08:24 -0700 Subject: [PATCH 1/9] Code changes to fix issues with credentials & options --- README.md | 30 ++----- Rakefile | 6 ++ .../src/resources/common/configurable.rb | 84 +++++++++++++++++++ .../src/resources/common/default.rb | 57 +++++++++++++ .../templates/client_template.template | 4 +- 5 files changed, 158 insertions(+), 23 deletions(-) create mode 100644 generators/profilegen/src/resources/common/configurable.rb create mode 100644 generators/profilegen/src/resources/common/default.rb diff --git a/README.md b/README.md index 3edb2f3090..8f7b256e6e 100644 --- a/README.md +++ b/README.md @@ -150,14 +150,10 @@ The following lines should be used to instantiate a profile client: ```ruby # Provide credentials -provider = MsRestAzure::ApplicationTokenProvider.new( - ENV['AZURE_TENANT_ID'], - ENV['AZURE_CLIENT_ID'], - ENV['AZURE_CLIENT_SECRET']) -credentials = MsRest::TokenCredentials.new(provider) - options = { - credentials: credentials, + tenant_id: ENV['AZURE_TENANT_ID'], + client_id: ENV['AZURE_CLIENT_ID'], + client_secret: ENV['AZURE_CLIENT_SECRET'], subscription_id: ENV['AZURE_SUBSCRIPTION_ID'] } @@ -195,14 +191,10 @@ The following lines should be used to instantiate a profile client: ```ruby # Provide credentials -provider = MsRestAzure::ApplicationTokenProvider.new( - ENV['AZURE_TENANT_ID'], - ENV['AZURE_CLIENT_ID'], - ENV['AZURE_CLIENT_SECRET']) -credentials = MsRest::TokenCredentials.new(provider) - options = { - credentials: credentials, + tenant_id: ENV['AZURE_TENANT_ID'], + client_id: ENV['AZURE_CLIENT_ID'], + client_secret: ENV['AZURE_CLIENT_SECRET'], subscription_id: ENV['AZURE_SUBSCRIPTION_ID'] } @@ -242,14 +234,10 @@ The following lines should be used to instantiate a profile client: ```ruby # Provide credentials -provider = MsRestAzure::ApplicationTokenProvider.new( - ENV['AZURE_TENANT_ID'], - ENV['AZURE_CLIENT_ID'], - ENV['AZURE_CLIENT_SECRET']) -credentials = MsRest::TokenCredentials.new(provider) - options = { - credentials: credentials, + tenant_id: ENV['AZURE_TENANT_ID'], + client_id: ENV['AZURE_CLIENT_ID'], + client_secret: ENV['AZURE_CLIENT_SECRET'], subscription_id: ENV['AZURE_SUBSCRIPTION_ID'] } diff --git a/Rakefile b/Rakefile index d02bc72bf4..13ad7616c3 100644 --- a/Rakefile +++ b/Rakefile @@ -172,6 +172,9 @@ namespace :arm do # bundle exec ruby profile_generator_client.rb --dir_metadata=dir_metadata.json --profile=profiles.json command = "#{get_base_profile_generation_cmd}#{get_profile_spec_files_folder}/#{PROFILE_METADATA[:azure_sdk]}" execute_and_stream(command) + + FileUtils.cp("#{__dir__}/generators/profilegen/src/resources/common/configurable.rb", "#{__dir__}/azure_sdk/lib/common/configurable.rb") + FileUtils.cp("#{__dir__}/generators/profilegen/src/resources/common/default.rb", "#{__dir__}/azure_sdk/lib/common/default.rb") end desc 'Regen individual profiles' @@ -183,6 +186,9 @@ namespace :arm do # bundle exec ruby profile_generator_client.rb --dir_metadata=dir_metadata.json --profile=authorization_profiles.json command = "#{get_base_profile_generation_cmd}#{get_profile_spec_files_folder}/#{profile_spec_file}" execute_and_stream(command) + + FileUtils.cp("#{__dir__}/generators/profilegen/src/resources/common/configurable.rb", "#{__dir__}/management/#{sdk}/lib/profiles/common/configurable.rb") + FileUtils.cp("#{__dir__}/generators/profilegen/src/resources/common/default.rb", "#{__dir__}/management/#{sdk}/lib/profiles/common/default.rb") end end end diff --git a/generators/profilegen/src/resources/common/configurable.rb b/generators/profilegen/src/resources/common/configurable.rb new file mode 100644 index 0000000000..5dfed0d57d --- /dev/null +++ b/generators/profilegen/src/resources/common/configurable.rb @@ -0,0 +1,84 @@ +# encoding: utf-8 +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. + +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. + module Configurable + # @return [String] Azure tenant id (also known as domain). + attr_accessor :tenant_id + + # @return [String] Azure client id. + attr_accessor :client_id + + # @return [String] Azure secret key. + attr_accessor :client_secret + + # @return [String] Azure subscription id. + attr_accessor :subscription_id + + # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure active directory service settings. + attr_accessor :active_directory_settings + + # @return [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client. + attr_accessor :credentials + + class << self + # + # List of configurable keys for {Azure::Common::Client}. + # @return [Array] of option keys. + # + def keys + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] + end + end + + # + # Set configuration options using a block. + # + def configure + yield self + end + + # + # Resets the configurable options to provided options or defaults. + # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. + # + def reset!(options = {}) + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] + instance_variable_set(:"@#{key}", options.fetch(key, default_value)) + end + + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + + self + end + + def config + self + end + + private + + # + # configures configurable options to default values + # + def setup_options + opts = {} + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] + end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) + opts + end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + + end +end diff --git a/generators/profilegen/src/resources/common/default.rb b/generators/profilegen/src/resources/common/default.rb new file mode 100644 index 0000000000..aa6d7c577b --- /dev/null +++ b/generators/profilegen/src/resources/common/default.rb @@ -0,0 +1,57 @@ +# encoding: utf-8 +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. + +module Azure::Common + module Default + class << self + # + # Default Azure Tenant Id. + # @return [String] Azure Tenant Id. + # + def tenant_id + ENV['AZURE_TENANT_ID'] + end + + # + # Default Azure Client Id. + # @return [String] Azure Client Id. + # + def client_id + ENV['AZURE_CLIENT_ID'] + end + + # + # Default Azure Client Secret. + # @return [String] Azure Client Secret. + # + def client_secret + ENV['AZURE_CLIENT_SECRET'] + end + + # + # Default Azure Subscription Id. + # @return [String] Azure Subscription Id. + # + def subscription_id + ENV['AZURE_SUBSCRIPTION_ID'] + end + + # + # Default Azure Active Directory Service Settings. + # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. + # + def active_directory_settings + MsRestAzure::ActiveDirectoryServiceSettings.get_azure_settings + end + + # + # Configuration options. + # @return [Hash] Configuration options. + # + def options + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] + end + end + end +end diff --git a/generators/profilegen/src/resources/templates/client_template.template b/generators/profilegen/src/resources/templates/client_template.template index 67f85ce46e..7ae931d863 100644 --- a/generators/profilegen/src/resources/templates/client_template.template +++ b/generators/profilegen/src/resources/templates/client_template.template @@ -31,7 +31,7 @@ module Azure::Profiles::<%= @profile_name %>::Mgmt <%- else -%> class Client <%- end -%> - include Azure::ARM::Configurable + include Azure::Common::Configurable <%- if !@individual_gem_profile -%> attr_reader <% @class_names.each_with_index do |class_name, index| %> :<%= class_name.gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase %><% if index != @class_names.length - 1 %>,<% end %><% end %> @@ -57,7 +57,7 @@ module Azure::Profiles::<%= @profile_name %>::Mgmt def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( From 258ab1cc9f9167b021f59b4c907bcd8ec8b47c6b Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 24 Oct 2017 23:50:35 -0700 Subject: [PATCH 2/9] Regen everything --- azure_sdk/lib/common/configurable.rb | 27 +++++++++++++------ azure_sdk/lib/common/default.rb | 15 ++--------- azure_sdk/lib/latest/latest_profile_client.rb | 4 +-- .../v2017_03_09/v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../analysisservices_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../authorization_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../automation_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/batch_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/billing_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/cdn_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...cognitiveservices_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/commerce_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/compute_latest_profile_client.rb | 4 +-- .../compute_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../consumption_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...containerinstance_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...containerregistry_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../containerservice_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../customerinsights_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...datalakeanalytics_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../datalakestore_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../devtestlabs_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/dns_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/eventgrid_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/eventhub_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/features_latest_profile_client.rb | 4 +-- .../features_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/graph_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/iothub_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/keyvault_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/links_latest_profile_client.rb | 4 +-- .../links_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/locks_latest_profile_client.rb | 4 +-- .../locks_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/logic_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../machinelearning_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...nagedapplications_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...rketplaceordering_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../mediaservices_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../mobileengagement_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/monitor_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/network_latest_profile_client.rb | 4 +-- .../network_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../notificationhubs_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...erationalinsights_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/policy_latest_profile_client.rb | 4 +-- .../policy_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../powerbiembedded_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../recoveryservices_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...eryservicesbackup_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...vicessiterecovery_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/redis_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/relay_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/resources_latest_profile_client.rb | 4 +-- .../resources_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...sourcesmanagement_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/scheduler_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/search_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../servermanagement_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../servicebus_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../servicefabric_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/sql_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- ...rsimple8000series_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/storage_latest_profile_client.rb | 4 +-- .../storage_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../streamanalytics_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../subscriptions_latest_profile_client.rb | 4 +-- ...ubscriptions_v2017_03_09_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../trafficmanager_latest_profile_client.rb | 4 +-- .../lib/profiles/common/configurable.rb | 27 +++++++++++++------ .../lib/profiles/common/default.rb | 15 ++--------- .../latest/web_latest_profile_client.rb | 4 +-- 184 files changed, 1354 insertions(+), 1354 deletions(-) diff --git a/azure_sdk/lib/common/configurable.rb b/azure_sdk/lib/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/azure_sdk/lib/common/configurable.rb +++ b/azure_sdk/lib/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/azure_sdk/lib/common/default.rb b/azure_sdk/lib/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/azure_sdk/lib/common/default.rb +++ b/azure_sdk/lib/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/azure_sdk/lib/latest/latest_profile_client.rb b/azure_sdk/lib/latest/latest_profile_client.rb index 6faf3987d7..cf4b5c81c6 100644 --- a/azure_sdk/lib/latest/latest_profile_client.rb +++ b/azure_sdk/lib/latest/latest_profile_client.rb @@ -68,7 +68,7 @@ module Azure::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client - include Azure::ARM::Configurable + include Azure::Common::Configurable attr_reader :analysis_services, :authorization, :automation, :batch, :billing, :cdn, :cognitive_services, :commerce, :compute, :consumption, :container_instance, :container_registry, :container_service, :customer_insights, :data_lake_analytics, :data_lake_store, :dev_test_labs, :dns, :event_grid, :event_hub, :features, :graph, :iot_hub, :key_vault, :links, :locks, :logic, :machine_learning, :managed_applications, :marketplace_ordering, :media_services, :mobile_engagement, :monitor, :network, :notification_hubs, :operational_insights, :policy, :power_bi_embedded, :recovery_services, :recovery_services_backup, :recovery_services_site_recovery, :redis, :relay, :resources, :resources_management, :scheduler, :search, :server_management, :service_bus, :service_fabric, :sql, :stor_simple8000_series, :storage, :stream_analytics, :subscriptions, :traffic_manager, :web @@ -142,7 +142,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb b/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb index ef6d48ff13..6233fb3f29 100644 --- a/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb +++ b/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb @@ -20,7 +20,7 @@ module Azure::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client - include Azure::ARM::Configurable + include Azure::Common::Configurable attr_reader :storage, :network, :compute, :features, :links, :locks, :policy, :resources, :subscriptions @@ -46,7 +46,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_analysis_services/lib/profiles/common/default.rb b/management/azure_mgmt_analysis_services/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_analysis_services/lib/profiles/common/default.rb +++ b/management/azure_mgmt_analysis_services/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_analysis_services/lib/profiles/latest/analysisservices_latest_profile_client.rb b/management/azure_mgmt_analysis_services/lib/profiles/latest/analysisservices_latest_profile_client.rb index d62f771dad..4f3f15430c 100644 --- a/management/azure_mgmt_analysis_services/lib/profiles/latest/analysisservices_latest_profile_client.rb +++ b/management/azure_mgmt_analysis_services/lib/profiles/latest/analysisservices_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::AnalysisServices::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < AnalysisServicesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb b/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_authorization/lib/profiles/common/default.rb b/management/azure_mgmt_authorization/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_authorization/lib/profiles/common/default.rb +++ b/management/azure_mgmt_authorization/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_authorization/lib/profiles/latest/authorization_latest_profile_client.rb b/management/azure_mgmt_authorization/lib/profiles/latest/authorization_latest_profile_client.rb index 85073c9f4f..68a93205fa 100644 --- a/management/azure_mgmt_authorization/lib/profiles/latest/authorization_latest_profile_client.rb +++ b/management/azure_mgmt_authorization/lib/profiles/latest/authorization_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Authorization::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < AuthorizationClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_automation/lib/profiles/common/configurable.rb b/management/azure_mgmt_automation/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_automation/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_automation/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_automation/lib/profiles/common/default.rb b/management/azure_mgmt_automation/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_automation/lib/profiles/common/default.rb +++ b/management/azure_mgmt_automation/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_automation/lib/profiles/latest/automation_latest_profile_client.rb b/management/azure_mgmt_automation/lib/profiles/latest/automation_latest_profile_client.rb index 7cb8572ab2..1f1924267d 100644 --- a/management/azure_mgmt_automation/lib/profiles/latest/automation_latest_profile_client.rb +++ b/management/azure_mgmt_automation/lib/profiles/latest/automation_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Automation::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < AutomationClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_batch/lib/profiles/common/configurable.rb b/management/azure_mgmt_batch/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_batch/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_batch/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_batch/lib/profiles/common/default.rb b/management/azure_mgmt_batch/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_batch/lib/profiles/common/default.rb +++ b/management/azure_mgmt_batch/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_batch/lib/profiles/latest/batch_latest_profile_client.rb b/management/azure_mgmt_batch/lib/profiles/latest/batch_latest_profile_client.rb index 493fb46220..29eb2e753c 100644 --- a/management/azure_mgmt_batch/lib/profiles/latest/batch_latest_profile_client.rb +++ b/management/azure_mgmt_batch/lib/profiles/latest/batch_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Batch::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < BatchClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_billing/lib/profiles/common/configurable.rb b/management/azure_mgmt_billing/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_billing/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_billing/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_billing/lib/profiles/common/default.rb b/management/azure_mgmt_billing/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_billing/lib/profiles/common/default.rb +++ b/management/azure_mgmt_billing/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_billing/lib/profiles/latest/billing_latest_profile_client.rb b/management/azure_mgmt_billing/lib/profiles/latest/billing_latest_profile_client.rb index bc8b263273..28effe762d 100644 --- a/management/azure_mgmt_billing/lib/profiles/latest/billing_latest_profile_client.rb +++ b/management/azure_mgmt_billing/lib/profiles/latest/billing_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Billing::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < BillingClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb b/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_cdn/lib/profiles/common/default.rb b/management/azure_mgmt_cdn/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_cdn/lib/profiles/common/default.rb +++ b/management/azure_mgmt_cdn/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_cdn/lib/profiles/latest/cdn_latest_profile_client.rb b/management/azure_mgmt_cdn/lib/profiles/latest/cdn_latest_profile_client.rb index c933eb1705..8636259d3d 100644 --- a/management/azure_mgmt_cdn/lib/profiles/latest/cdn_latest_profile_client.rb +++ b/management/azure_mgmt_cdn/lib/profiles/latest/cdn_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::CDN::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < CDNClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_cognitive_services/lib/profiles/common/default.rb b/management/azure_mgmt_cognitive_services/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_cognitive_services/lib/profiles/common/default.rb +++ b/management/azure_mgmt_cognitive_services/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_cognitive_services/lib/profiles/latest/cognitiveservices_latest_profile_client.rb b/management/azure_mgmt_cognitive_services/lib/profiles/latest/cognitiveservices_latest_profile_client.rb index 38dd8db55f..13fa68c147 100644 --- a/management/azure_mgmt_cognitive_services/lib/profiles/latest/cognitiveservices_latest_profile_client.rb +++ b/management/azure_mgmt_cognitive_services/lib/profiles/latest/cognitiveservices_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::CognitiveServices::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < CognitiveServicesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb b/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_commerce/lib/profiles/common/default.rb b/management/azure_mgmt_commerce/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_commerce/lib/profiles/common/default.rb +++ b/management/azure_mgmt_commerce/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_commerce/lib/profiles/latest/commerce_latest_profile_client.rb b/management/azure_mgmt_commerce/lib/profiles/latest/commerce_latest_profile_client.rb index e8641b7d29..25af12921f 100644 --- a/management/azure_mgmt_commerce/lib/profiles/latest/commerce_latest_profile_client.rb +++ b/management/azure_mgmt_commerce/lib/profiles/latest/commerce_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Commerce::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < CommerceClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_compute/lib/profiles/common/configurable.rb b/management/azure_mgmt_compute/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_compute/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_compute/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_compute/lib/profiles/common/default.rb b/management/azure_mgmt_compute/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_compute/lib/profiles/common/default.rb +++ b/management/azure_mgmt_compute/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_compute/lib/profiles/latest/compute_latest_profile_client.rb b/management/azure_mgmt_compute/lib/profiles/latest/compute_latest_profile_client.rb index 140adf3a23..5e0059343a 100644 --- a/management/azure_mgmt_compute/lib/profiles/latest/compute_latest_profile_client.rb +++ b/management/azure_mgmt_compute/lib/profiles/latest/compute_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Compute::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ComputeClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_compute/lib/profiles/v2017_03_09/compute_v2017_03_09_profile_client.rb b/management/azure_mgmt_compute/lib/profiles/v2017_03_09/compute_v2017_03_09_profile_client.rb index 31d178f352..7fc6e4a380 100644 --- a/management/azure_mgmt_compute/lib/profiles/v2017_03_09/compute_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_compute/lib/profiles/v2017_03_09/compute_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Compute::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < ComputeClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb b/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_consumption/lib/profiles/common/default.rb b/management/azure_mgmt_consumption/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_consumption/lib/profiles/common/default.rb +++ b/management/azure_mgmt_consumption/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_consumption/lib/profiles/latest/consumption_latest_profile_client.rb b/management/azure_mgmt_consumption/lib/profiles/latest/consumption_latest_profile_client.rb index 34563e02b2..c981955331 100644 --- a/management/azure_mgmt_consumption/lib/profiles/latest/consumption_latest_profile_client.rb +++ b/management/azure_mgmt_consumption/lib/profiles/latest/consumption_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Consumption::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ConsumptionClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_container_instance/lib/profiles/common/default.rb b/management/azure_mgmt_container_instance/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_container_instance/lib/profiles/common/default.rb +++ b/management/azure_mgmt_container_instance/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_container_instance/lib/profiles/latest/containerinstance_latest_profile_client.rb b/management/azure_mgmt_container_instance/lib/profiles/latest/containerinstance_latest_profile_client.rb index 6aa9ff6633..115bc6477b 100644 --- a/management/azure_mgmt_container_instance/lib/profiles/latest/containerinstance_latest_profile_client.rb +++ b/management/azure_mgmt_container_instance/lib/profiles/latest/containerinstance_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::ContainerInstance::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ContainerInstanceClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_container_registry/lib/profiles/common/default.rb b/management/azure_mgmt_container_registry/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_container_registry/lib/profiles/common/default.rb +++ b/management/azure_mgmt_container_registry/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_container_registry/lib/profiles/latest/containerregistry_latest_profile_client.rb b/management/azure_mgmt_container_registry/lib/profiles/latest/containerregistry_latest_profile_client.rb index d8a8406dfd..5938465471 100644 --- a/management/azure_mgmt_container_registry/lib/profiles/latest/containerregistry_latest_profile_client.rb +++ b/management/azure_mgmt_container_registry/lib/profiles/latest/containerregistry_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::ContainerRegistry::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ContainerRegistryClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_container_service/lib/profiles/common/default.rb b/management/azure_mgmt_container_service/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_container_service/lib/profiles/common/default.rb +++ b/management/azure_mgmt_container_service/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_container_service/lib/profiles/latest/containerservice_latest_profile_client.rb b/management/azure_mgmt_container_service/lib/profiles/latest/containerservice_latest_profile_client.rb index 03cb6c304d..5237c13563 100644 --- a/management/azure_mgmt_container_service/lib/profiles/latest/containerservice_latest_profile_client.rb +++ b/management/azure_mgmt_container_service/lib/profiles/latest/containerservice_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::ContainerService::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ContainerServiceClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb b/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_customer_insights/lib/profiles/common/default.rb b/management/azure_mgmt_customer_insights/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_customer_insights/lib/profiles/common/default.rb +++ b/management/azure_mgmt_customer_insights/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_customer_insights/lib/profiles/latest/customerinsights_latest_profile_client.rb b/management/azure_mgmt_customer_insights/lib/profiles/latest/customerinsights_latest_profile_client.rb index f0d203b55a..1150e25c48 100644 --- a/management/azure_mgmt_customer_insights/lib/profiles/latest/customerinsights_latest_profile_client.rb +++ b/management/azure_mgmt_customer_insights/lib/profiles/latest/customerinsights_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::CustomerInsights::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < CustomerInsightsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb b/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_datalake_analytics/lib/profiles/common/default.rb b/management/azure_mgmt_datalake_analytics/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_datalake_analytics/lib/profiles/common/default.rb +++ b/management/azure_mgmt_datalake_analytics/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_datalake_analytics/lib/profiles/latest/datalakeanalytics_latest_profile_client.rb b/management/azure_mgmt_datalake_analytics/lib/profiles/latest/datalakeanalytics_latest_profile_client.rb index 2486298c02..a9a180e7dd 100644 --- a/management/azure_mgmt_datalake_analytics/lib/profiles/latest/datalakeanalytics_latest_profile_client.rb +++ b/management/azure_mgmt_datalake_analytics/lib/profiles/latest/datalakeanalytics_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::DataLakeAnalytics::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < DataLakeAnalyticsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb b/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_datalake_store/lib/profiles/common/default.rb b/management/azure_mgmt_datalake_store/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_datalake_store/lib/profiles/common/default.rb +++ b/management/azure_mgmt_datalake_store/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_datalake_store/lib/profiles/latest/datalakestore_latest_profile_client.rb b/management/azure_mgmt_datalake_store/lib/profiles/latest/datalakestore_latest_profile_client.rb index f9821007b2..7a2c62e59c 100644 --- a/management/azure_mgmt_datalake_store/lib/profiles/latest/datalakestore_latest_profile_client.rb +++ b/management/azure_mgmt_datalake_store/lib/profiles/latest/datalakestore_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::DataLakeStore::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < DataLakeStoreClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb b/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_devtestlabs/lib/profiles/common/default.rb b/management/azure_mgmt_devtestlabs/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_devtestlabs/lib/profiles/common/default.rb +++ b/management/azure_mgmt_devtestlabs/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_devtestlabs/lib/profiles/latest/devtestlabs_latest_profile_client.rb b/management/azure_mgmt_devtestlabs/lib/profiles/latest/devtestlabs_latest_profile_client.rb index b08bedc8bb..0631183018 100644 --- a/management/azure_mgmt_devtestlabs/lib/profiles/latest/devtestlabs_latest_profile_client.rb +++ b/management/azure_mgmt_devtestlabs/lib/profiles/latest/devtestlabs_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::DevTestLabs::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < DevTestLabsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_dns/lib/profiles/common/configurable.rb b/management/azure_mgmt_dns/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_dns/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_dns/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_dns/lib/profiles/common/default.rb b/management/azure_mgmt_dns/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_dns/lib/profiles/common/default.rb +++ b/management/azure_mgmt_dns/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_dns/lib/profiles/latest/dns_latest_profile_client.rb b/management/azure_mgmt_dns/lib/profiles/latest/dns_latest_profile_client.rb index fda838123a..b2363c1107 100644 --- a/management/azure_mgmt_dns/lib/profiles/latest/dns_latest_profile_client.rb +++ b/management/azure_mgmt_dns/lib/profiles/latest/dns_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Dns::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < DnsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb b/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_event_grid/lib/profiles/common/default.rb b/management/azure_mgmt_event_grid/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_event_grid/lib/profiles/common/default.rb +++ b/management/azure_mgmt_event_grid/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_event_grid/lib/profiles/latest/eventgrid_latest_profile_client.rb b/management/azure_mgmt_event_grid/lib/profiles/latest/eventgrid_latest_profile_client.rb index e674fd6f72..d55a0517d3 100644 --- a/management/azure_mgmt_event_grid/lib/profiles/latest/eventgrid_latest_profile_client.rb +++ b/management/azure_mgmt_event_grid/lib/profiles/latest/eventgrid_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::EventGrid::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < EventGridClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb b/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_event_hub/lib/profiles/common/default.rb b/management/azure_mgmt_event_hub/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_event_hub/lib/profiles/common/default.rb +++ b/management/azure_mgmt_event_hub/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_event_hub/lib/profiles/latest/eventhub_latest_profile_client.rb b/management/azure_mgmt_event_hub/lib/profiles/latest/eventhub_latest_profile_client.rb index 8042f4ac6f..f7b8f951e9 100644 --- a/management/azure_mgmt_event_hub/lib/profiles/latest/eventhub_latest_profile_client.rb +++ b/management/azure_mgmt_event_hub/lib/profiles/latest/eventhub_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::EventHub::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < EventHubClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_features/lib/profiles/common/configurable.rb b/management/azure_mgmt_features/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_features/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_features/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_features/lib/profiles/common/default.rb b/management/azure_mgmt_features/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_features/lib/profiles/common/default.rb +++ b/management/azure_mgmt_features/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_features/lib/profiles/latest/features_latest_profile_client.rb b/management/azure_mgmt_features/lib/profiles/latest/features_latest_profile_client.rb index 11e17d51b9..13481de7da 100644 --- a/management/azure_mgmt_features/lib/profiles/latest/features_latest_profile_client.rb +++ b/management/azure_mgmt_features/lib/profiles/latest/features_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Features::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < FeaturesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_features/lib/profiles/v2017_03_09/features_v2017_03_09_profile_client.rb b/management/azure_mgmt_features/lib/profiles/v2017_03_09/features_v2017_03_09_profile_client.rb index 6ce0044fa2..c00f3dd21a 100644 --- a/management/azure_mgmt_features/lib/profiles/v2017_03_09/features_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_features/lib/profiles/v2017_03_09/features_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Features::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < FeaturesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_graph/lib/profiles/common/configurable.rb b/management/azure_mgmt_graph/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_graph/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_graph/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_graph/lib/profiles/common/default.rb b/management/azure_mgmt_graph/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_graph/lib/profiles/common/default.rb +++ b/management/azure_mgmt_graph/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_graph/lib/profiles/latest/graph_latest_profile_client.rb b/management/azure_mgmt_graph/lib/profiles/latest/graph_latest_profile_client.rb index fbbe59e921..56cfb398bb 100644 --- a/management/azure_mgmt_graph/lib/profiles/latest/graph_latest_profile_client.rb +++ b/management/azure_mgmt_graph/lib/profiles/latest/graph_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Graph::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < GraphClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb b/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_iot_hub/lib/profiles/common/default.rb b/management/azure_mgmt_iot_hub/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_iot_hub/lib/profiles/common/default.rb +++ b/management/azure_mgmt_iot_hub/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_iot_hub/lib/profiles/latest/iothub_latest_profile_client.rb b/management/azure_mgmt_iot_hub/lib/profiles/latest/iothub_latest_profile_client.rb index 35f69793f8..dabfa663d8 100644 --- a/management/azure_mgmt_iot_hub/lib/profiles/latest/iothub_latest_profile_client.rb +++ b/management/azure_mgmt_iot_hub/lib/profiles/latest/iothub_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::IotHub::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < IotHubClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb b/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_key_vault/lib/profiles/common/default.rb b/management/azure_mgmt_key_vault/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_key_vault/lib/profiles/common/default.rb +++ b/management/azure_mgmt_key_vault/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_key_vault/lib/profiles/latest/keyvault_latest_profile_client.rb b/management/azure_mgmt_key_vault/lib/profiles/latest/keyvault_latest_profile_client.rb index ceb1788c7f..56e41b0fa1 100644 --- a/management/azure_mgmt_key_vault/lib/profiles/latest/keyvault_latest_profile_client.rb +++ b/management/azure_mgmt_key_vault/lib/profiles/latest/keyvault_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::KeyVault::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < KeyVaultClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_links/lib/profiles/common/configurable.rb b/management/azure_mgmt_links/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_links/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_links/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_links/lib/profiles/common/default.rb b/management/azure_mgmt_links/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_links/lib/profiles/common/default.rb +++ b/management/azure_mgmt_links/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_links/lib/profiles/latest/links_latest_profile_client.rb b/management/azure_mgmt_links/lib/profiles/latest/links_latest_profile_client.rb index e296bbda9c..d13db264fa 100644 --- a/management/azure_mgmt_links/lib/profiles/latest/links_latest_profile_client.rb +++ b/management/azure_mgmt_links/lib/profiles/latest/links_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Links::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < LinksClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_links/lib/profiles/v2017_03_09/links_v2017_03_09_profile_client.rb b/management/azure_mgmt_links/lib/profiles/v2017_03_09/links_v2017_03_09_profile_client.rb index a942a3ef86..f09c63ddd5 100644 --- a/management/azure_mgmt_links/lib/profiles/v2017_03_09/links_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_links/lib/profiles/v2017_03_09/links_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Links::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < LinksClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_locks/lib/profiles/common/configurable.rb b/management/azure_mgmt_locks/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_locks/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_locks/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_locks/lib/profiles/common/default.rb b/management/azure_mgmt_locks/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_locks/lib/profiles/common/default.rb +++ b/management/azure_mgmt_locks/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_locks/lib/profiles/latest/locks_latest_profile_client.rb b/management/azure_mgmt_locks/lib/profiles/latest/locks_latest_profile_client.rb index 9e87ebbb76..684a2e1212 100644 --- a/management/azure_mgmt_locks/lib/profiles/latest/locks_latest_profile_client.rb +++ b/management/azure_mgmt_locks/lib/profiles/latest/locks_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Locks::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < LocksClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_locks/lib/profiles/v2017_03_09/locks_v2017_03_09_profile_client.rb b/management/azure_mgmt_locks/lib/profiles/v2017_03_09/locks_v2017_03_09_profile_client.rb index 4e712eadea..34248cf0cb 100644 --- a/management/azure_mgmt_locks/lib/profiles/v2017_03_09/locks_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_locks/lib/profiles/v2017_03_09/locks_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Locks::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < LocksClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_logic/lib/profiles/common/configurable.rb b/management/azure_mgmt_logic/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_logic/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_logic/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_logic/lib/profiles/common/default.rb b/management/azure_mgmt_logic/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_logic/lib/profiles/common/default.rb +++ b/management/azure_mgmt_logic/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_logic/lib/profiles/latest/logic_latest_profile_client.rb b/management/azure_mgmt_logic/lib/profiles/latest/logic_latest_profile_client.rb index 013036aabf..6568818599 100644 --- a/management/azure_mgmt_logic/lib/profiles/latest/logic_latest_profile_client.rb +++ b/management/azure_mgmt_logic/lib/profiles/latest/logic_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Logic::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < LogicClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb b/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_machine_learning/lib/profiles/common/default.rb b/management/azure_mgmt_machine_learning/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_machine_learning/lib/profiles/common/default.rb +++ b/management/azure_mgmt_machine_learning/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_machine_learning/lib/profiles/latest/machinelearning_latest_profile_client.rb b/management/azure_mgmt_machine_learning/lib/profiles/latest/machinelearning_latest_profile_client.rb index 8ca5e24997..0310b3a741 100644 --- a/management/azure_mgmt_machine_learning/lib/profiles/latest/machinelearning_latest_profile_client.rb +++ b/management/azure_mgmt_machine_learning/lib/profiles/latest/machinelearning_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::MachineLearning::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < MachineLearningClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb b/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_managed_applications/lib/profiles/common/default.rb b/management/azure_mgmt_managed_applications/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_managed_applications/lib/profiles/common/default.rb +++ b/management/azure_mgmt_managed_applications/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_managed_applications/lib/profiles/latest/managedapplications_latest_profile_client.rb b/management/azure_mgmt_managed_applications/lib/profiles/latest/managedapplications_latest_profile_client.rb index cffaf734fa..92d04fdb3d 100644 --- a/management/azure_mgmt_managed_applications/lib/profiles/latest/managedapplications_latest_profile_client.rb +++ b/management/azure_mgmt_managed_applications/lib/profiles/latest/managedapplications_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::ManagedApplications::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ManagedApplicationsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb b/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_marketplace_ordering/lib/profiles/common/default.rb b/management/azure_mgmt_marketplace_ordering/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_marketplace_ordering/lib/profiles/common/default.rb +++ b/management/azure_mgmt_marketplace_ordering/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/marketplaceordering_latest_profile_client.rb b/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/marketplaceordering_latest_profile_client.rb index 66416ba0b9..9c2cb932c7 100644 --- a/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/marketplaceordering_latest_profile_client.rb +++ b/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/marketplaceordering_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::MarketplaceOrdering::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < MarketplaceOrderingClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_media_services/lib/profiles/common/default.rb b/management/azure_mgmt_media_services/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_media_services/lib/profiles/common/default.rb +++ b/management/azure_mgmt_media_services/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_media_services/lib/profiles/latest/mediaservices_latest_profile_client.rb b/management/azure_mgmt_media_services/lib/profiles/latest/mediaservices_latest_profile_client.rb index f2a5952bf7..db43cd6398 100644 --- a/management/azure_mgmt_media_services/lib/profiles/latest/mediaservices_latest_profile_client.rb +++ b/management/azure_mgmt_media_services/lib/profiles/latest/mediaservices_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::MediaServices::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < MediaServicesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb b/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_mobile_engagement/lib/profiles/common/default.rb b/management/azure_mgmt_mobile_engagement/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_mobile_engagement/lib/profiles/common/default.rb +++ b/management/azure_mgmt_mobile_engagement/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_mobile_engagement/lib/profiles/latest/mobileengagement_latest_profile_client.rb b/management/azure_mgmt_mobile_engagement/lib/profiles/latest/mobileengagement_latest_profile_client.rb index 19737e628e..62430fc176 100644 --- a/management/azure_mgmt_mobile_engagement/lib/profiles/latest/mobileengagement_latest_profile_client.rb +++ b/management/azure_mgmt_mobile_engagement/lib/profiles/latest/mobileengagement_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::MobileEngagement::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < MobileEngagementClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb b/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_monitor/lib/profiles/common/default.rb b/management/azure_mgmt_monitor/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_monitor/lib/profiles/common/default.rb +++ b/management/azure_mgmt_monitor/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_monitor/lib/profiles/latest/monitor_latest_profile_client.rb b/management/azure_mgmt_monitor/lib/profiles/latest/monitor_latest_profile_client.rb index 2b16aee2ff..2250141e67 100644 --- a/management/azure_mgmt_monitor/lib/profiles/latest/monitor_latest_profile_client.rb +++ b/management/azure_mgmt_monitor/lib/profiles/latest/monitor_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Monitor::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < MonitorClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_network/lib/profiles/common/configurable.rb b/management/azure_mgmt_network/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_network/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_network/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_network/lib/profiles/common/default.rb b/management/azure_mgmt_network/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_network/lib/profiles/common/default.rb +++ b/management/azure_mgmt_network/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_network/lib/profiles/latest/network_latest_profile_client.rb b/management/azure_mgmt_network/lib/profiles/latest/network_latest_profile_client.rb index 3835ebc4a2..347234a3d0 100644 --- a/management/azure_mgmt_network/lib/profiles/latest/network_latest_profile_client.rb +++ b/management/azure_mgmt_network/lib/profiles/latest/network_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Network::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < NetworkClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_network/lib/profiles/v2017_03_09/network_v2017_03_09_profile_client.rb b/management/azure_mgmt_network/lib/profiles/v2017_03_09/network_v2017_03_09_profile_client.rb index 842aaf0961..20901663b5 100644 --- a/management/azure_mgmt_network/lib/profiles/v2017_03_09/network_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_network/lib/profiles/v2017_03_09/network_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Network::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < NetworkClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb b/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_notification_hubs/lib/profiles/common/default.rb b/management/azure_mgmt_notification_hubs/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_notification_hubs/lib/profiles/common/default.rb +++ b/management/azure_mgmt_notification_hubs/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_notification_hubs/lib/profiles/latest/notificationhubs_latest_profile_client.rb b/management/azure_mgmt_notification_hubs/lib/profiles/latest/notificationhubs_latest_profile_client.rb index d7c05aad19..4127145a50 100644 --- a/management/azure_mgmt_notification_hubs/lib/profiles/latest/notificationhubs_latest_profile_client.rb +++ b/management/azure_mgmt_notification_hubs/lib/profiles/latest/notificationhubs_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::NotificationHubs::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < NotificationHubsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb b/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_operational_insights/lib/profiles/common/default.rb b/management/azure_mgmt_operational_insights/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_operational_insights/lib/profiles/common/default.rb +++ b/management/azure_mgmt_operational_insights/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_operational_insights/lib/profiles/latest/operationalinsights_latest_profile_client.rb b/management/azure_mgmt_operational_insights/lib/profiles/latest/operationalinsights_latest_profile_client.rb index bf019e3d31..24103aea71 100644 --- a/management/azure_mgmt_operational_insights/lib/profiles/latest/operationalinsights_latest_profile_client.rb +++ b/management/azure_mgmt_operational_insights/lib/profiles/latest/operationalinsights_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::OperationalInsights::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < OperationalInsightsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_policy/lib/profiles/common/configurable.rb b/management/azure_mgmt_policy/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_policy/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_policy/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_policy/lib/profiles/common/default.rb b/management/azure_mgmt_policy/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_policy/lib/profiles/common/default.rb +++ b/management/azure_mgmt_policy/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_policy/lib/profiles/latest/policy_latest_profile_client.rb b/management/azure_mgmt_policy/lib/profiles/latest/policy_latest_profile_client.rb index 5a7d852070..bee4b91224 100644 --- a/management/azure_mgmt_policy/lib/profiles/latest/policy_latest_profile_client.rb +++ b/management/azure_mgmt_policy/lib/profiles/latest/policy_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Policy::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < PolicyClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_policy/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb b/management/azure_mgmt_policy/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb index c87251682f..064ec6627c 100644 --- a/management/azure_mgmt_policy/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_policy/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Policy::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < PolicyClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb b/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_powerbi_embedded/lib/profiles/common/default.rb b/management/azure_mgmt_powerbi_embedded/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_powerbi_embedded/lib/profiles/common/default.rb +++ b/management/azure_mgmt_powerbi_embedded/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/powerbiembedded_latest_profile_client.rb b/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/powerbiembedded_latest_profile_client.rb index 5f83ac5b84..c2b0fbc285 100644 --- a/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/powerbiembedded_latest_profile_client.rb +++ b/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/powerbiembedded_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::PowerBiEmbedded::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < PowerBiEmbeddedClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_recovery_services/lib/profiles/common/default.rb b/management/azure_mgmt_recovery_services/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_recovery_services/lib/profiles/common/default.rb +++ b/management/azure_mgmt_recovery_services/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_recovery_services/lib/profiles/latest/recoveryservices_latest_profile_client.rb b/management/azure_mgmt_recovery_services/lib/profiles/latest/recoveryservices_latest_profile_client.rb index d1d6f57364..98de47b9d7 100644 --- a/management/azure_mgmt_recovery_services/lib/profiles/latest/recoveryservices_latest_profile_client.rb +++ b/management/azure_mgmt_recovery_services/lib/profiles/latest/recoveryservices_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::RecoveryServices::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < RecoveryServicesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_recovery_services_backup/lib/profiles/common/default.rb b/management/azure_mgmt_recovery_services_backup/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_recovery_services_backup/lib/profiles/common/default.rb +++ b/management/azure_mgmt_recovery_services_backup/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/recoveryservicesbackup_latest_profile_client.rb b/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/recoveryservicesbackup_latest_profile_client.rb index 3039dbfee7..1459aff9e9 100644 --- a/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/recoveryservicesbackup_latest_profile_client.rb +++ b/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/recoveryservicesbackup_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::RecoveryServicesBackup::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < RecoveryServicesBackupClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/default.rb b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/default.rb +++ b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/recoveryservicessiterecovery_latest_profile_client.rb b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/recoveryservicessiterecovery_latest_profile_client.rb index e69d56a2d2..780c49f788 100644 --- a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/recoveryservicessiterecovery_latest_profile_client.rb +++ b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/recoveryservicessiterecovery_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::RecoveryServicesSiteRecovery::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < RecoveryServicesSiteRecoveryClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_redis/lib/profiles/common/configurable.rb b/management/azure_mgmt_redis/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_redis/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_redis/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_redis/lib/profiles/common/default.rb b/management/azure_mgmt_redis/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_redis/lib/profiles/common/default.rb +++ b/management/azure_mgmt_redis/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_redis/lib/profiles/latest/redis_latest_profile_client.rb b/management/azure_mgmt_redis/lib/profiles/latest/redis_latest_profile_client.rb index f820fcdc65..119732a1a2 100644 --- a/management/azure_mgmt_redis/lib/profiles/latest/redis_latest_profile_client.rb +++ b/management/azure_mgmt_redis/lib/profiles/latest/redis_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Redis::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < RedisClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_relay/lib/profiles/common/configurable.rb b/management/azure_mgmt_relay/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_relay/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_relay/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_relay/lib/profiles/common/default.rb b/management/azure_mgmt_relay/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_relay/lib/profiles/common/default.rb +++ b/management/azure_mgmt_relay/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_relay/lib/profiles/latest/relay_latest_profile_client.rb b/management/azure_mgmt_relay/lib/profiles/latest/relay_latest_profile_client.rb index d55a8f61dc..edd2526bea 100644 --- a/management/azure_mgmt_relay/lib/profiles/latest/relay_latest_profile_client.rb +++ b/management/azure_mgmt_relay/lib/profiles/latest/relay_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Relay::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < RelayClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_resources/lib/profiles/common/configurable.rb b/management/azure_mgmt_resources/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_resources/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_resources/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_resources/lib/profiles/common/default.rb b/management/azure_mgmt_resources/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_resources/lib/profiles/common/default.rb +++ b/management/azure_mgmt_resources/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_resources/lib/profiles/latest/resources_latest_profile_client.rb b/management/azure_mgmt_resources/lib/profiles/latest/resources_latest_profile_client.rb index f951c8fcfb..eb6feeba5d 100644 --- a/management/azure_mgmt_resources/lib/profiles/latest/resources_latest_profile_client.rb +++ b/management/azure_mgmt_resources/lib/profiles/latest/resources_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Resources::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ResourcesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_resources/lib/profiles/v2017_03_09/resources_v2017_03_09_profile_client.rb b/management/azure_mgmt_resources/lib/profiles/v2017_03_09/resources_v2017_03_09_profile_client.rb index fec31aaab0..6254f68431 100644 --- a/management/azure_mgmt_resources/lib/profiles/v2017_03_09/resources_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_resources/lib/profiles/v2017_03_09/resources_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Resources::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < ResourcesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb b/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_resources_management/lib/profiles/common/default.rb b/management/azure_mgmt_resources_management/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_resources_management/lib/profiles/common/default.rb +++ b/management/azure_mgmt_resources_management/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_resources_management/lib/profiles/latest/resourcesmanagement_latest_profile_client.rb b/management/azure_mgmt_resources_management/lib/profiles/latest/resourcesmanagement_latest_profile_client.rb index 3d0a964ea7..2fac9d1e74 100644 --- a/management/azure_mgmt_resources_management/lib/profiles/latest/resourcesmanagement_latest_profile_client.rb +++ b/management/azure_mgmt_resources_management/lib/profiles/latest/resourcesmanagement_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::ResourcesManagement::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ResourcesManagementClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb b/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_scheduler/lib/profiles/common/default.rb b/management/azure_mgmt_scheduler/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_scheduler/lib/profiles/common/default.rb +++ b/management/azure_mgmt_scheduler/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_scheduler/lib/profiles/latest/scheduler_latest_profile_client.rb b/management/azure_mgmt_scheduler/lib/profiles/latest/scheduler_latest_profile_client.rb index 63d0252ea7..21b57a5f13 100644 --- a/management/azure_mgmt_scheduler/lib/profiles/latest/scheduler_latest_profile_client.rb +++ b/management/azure_mgmt_scheduler/lib/profiles/latest/scheduler_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Scheduler::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < SchedulerClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_search/lib/profiles/common/configurable.rb b/management/azure_mgmt_search/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_search/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_search/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_search/lib/profiles/common/default.rb b/management/azure_mgmt_search/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_search/lib/profiles/common/default.rb +++ b/management/azure_mgmt_search/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_search/lib/profiles/latest/search_latest_profile_client.rb b/management/azure_mgmt_search/lib/profiles/latest/search_latest_profile_client.rb index b7552bbe63..412dc8970a 100644 --- a/management/azure_mgmt_search/lib/profiles/latest/search_latest_profile_client.rb +++ b/management/azure_mgmt_search/lib/profiles/latest/search_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Search::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < SearchClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb b/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_server_management/lib/profiles/common/default.rb b/management/azure_mgmt_server_management/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_server_management/lib/profiles/common/default.rb +++ b/management/azure_mgmt_server_management/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_server_management/lib/profiles/latest/servermanagement_latest_profile_client.rb b/management/azure_mgmt_server_management/lib/profiles/latest/servermanagement_latest_profile_client.rb index 7331101cfe..78cb1a8898 100644 --- a/management/azure_mgmt_server_management/lib/profiles/latest/servermanagement_latest_profile_client.rb +++ b/management/azure_mgmt_server_management/lib/profiles/latest/servermanagement_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::ServerManagement::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ServerManagementClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb b/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_service_bus/lib/profiles/common/default.rb b/management/azure_mgmt_service_bus/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_service_bus/lib/profiles/common/default.rb +++ b/management/azure_mgmt_service_bus/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_service_bus/lib/profiles/latest/servicebus_latest_profile_client.rb b/management/azure_mgmt_service_bus/lib/profiles/latest/servicebus_latest_profile_client.rb index cd19825188..7eeb60fee1 100644 --- a/management/azure_mgmt_service_bus/lib/profiles/latest/servicebus_latest_profile_client.rb +++ b/management/azure_mgmt_service_bus/lib/profiles/latest/servicebus_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::ServiceBus::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ServiceBusClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb b/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_service_fabric/lib/profiles/common/default.rb b/management/azure_mgmt_service_fabric/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_service_fabric/lib/profiles/common/default.rb +++ b/management/azure_mgmt_service_fabric/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_service_fabric/lib/profiles/latest/servicefabric_latest_profile_client.rb b/management/azure_mgmt_service_fabric/lib/profiles/latest/servicefabric_latest_profile_client.rb index 6722f25e96..71c26c3ff3 100644 --- a/management/azure_mgmt_service_fabric/lib/profiles/latest/servicefabric_latest_profile_client.rb +++ b/management/azure_mgmt_service_fabric/lib/profiles/latest/servicefabric_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::ServiceFabric::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < ServiceFabricClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_sql/lib/profiles/common/configurable.rb b/management/azure_mgmt_sql/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_sql/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_sql/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_sql/lib/profiles/common/default.rb b/management/azure_mgmt_sql/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_sql/lib/profiles/common/default.rb +++ b/management/azure_mgmt_sql/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_sql/lib/profiles/latest/sql_latest_profile_client.rb b/management/azure_mgmt_sql/lib/profiles/latest/sql_latest_profile_client.rb index 1c6bd6e087..5014aea6d1 100644 --- a/management/azure_mgmt_sql/lib/profiles/latest/sql_latest_profile_client.rb +++ b/management/azure_mgmt_sql/lib/profiles/latest/sql_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::SQL::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < SQLClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb b/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/default.rb b/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/default.rb +++ b/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/storsimple8000series_latest_profile_client.rb b/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/storsimple8000series_latest_profile_client.rb index 547c30d3e1..2293923072 100644 --- a/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/storsimple8000series_latest_profile_client.rb +++ b/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/storsimple8000series_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::StorSimple8000Series::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < StorSimple8000SeriesClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_storage/lib/profiles/common/configurable.rb b/management/azure_mgmt_storage/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_storage/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_storage/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_storage/lib/profiles/common/default.rb b/management/azure_mgmt_storage/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_storage/lib/profiles/common/default.rb +++ b/management/azure_mgmt_storage/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_storage/lib/profiles/latest/storage_latest_profile_client.rb b/management/azure_mgmt_storage/lib/profiles/latest/storage_latest_profile_client.rb index 642d9799cb..ccf5712836 100644 --- a/management/azure_mgmt_storage/lib/profiles/latest/storage_latest_profile_client.rb +++ b/management/azure_mgmt_storage/lib/profiles/latest/storage_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Storage::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < StorageClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_storage/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb b/management/azure_mgmt_storage/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb index 662ec20c64..d0c25aafe1 100644 --- a/management/azure_mgmt_storage/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_storage/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Storage::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < StorageClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb b/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_stream_analytics/lib/profiles/common/default.rb b/management/azure_mgmt_stream_analytics/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_stream_analytics/lib/profiles/common/default.rb +++ b/management/azure_mgmt_stream_analytics/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_stream_analytics/lib/profiles/latest/streamanalytics_latest_profile_client.rb b/management/azure_mgmt_stream_analytics/lib/profiles/latest/streamanalytics_latest_profile_client.rb index 74aa83b1b5..e698e4aab3 100644 --- a/management/azure_mgmt_stream_analytics/lib/profiles/latest/streamanalytics_latest_profile_client.rb +++ b/management/azure_mgmt_stream_analytics/lib/profiles/latest/streamanalytics_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::StreamAnalytics::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < StreamAnalyticsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb b/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_subscriptions/lib/profiles/common/default.rb b/management/azure_mgmt_subscriptions/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/common/default.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_subscriptions/lib/profiles/latest/subscriptions_latest_profile_client.rb b/management/azure_mgmt_subscriptions/lib/profiles/latest/subscriptions_latest_profile_client.rb index b77e48a2ba..af94b13af3 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/latest/subscriptions_latest_profile_client.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/latest/subscriptions_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Subscriptions::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < SubscriptionsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/subscriptions_v2017_03_09_profile_client.rb b/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/subscriptions_v2017_03_09_profile_client.rb index ad908527ab..308f52f052 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/subscriptions_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/subscriptions_v2017_03_09_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Subscriptions::Profiles::V2017_03_09::Mgmt # Client class for the V2017_03_09 profile SDK. # class Client < SubscriptionsClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb b/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_traffic_manager/lib/profiles/common/default.rb b/management/azure_mgmt_traffic_manager/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_traffic_manager/lib/profiles/common/default.rb +++ b/management/azure_mgmt_traffic_manager/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_traffic_manager/lib/profiles/latest/trafficmanager_latest_profile_client.rb b/management/azure_mgmt_traffic_manager/lib/profiles/latest/trafficmanager_latest_profile_client.rb index bae6081d07..0b35a8c23a 100644 --- a/management/azure_mgmt_traffic_manager/lib/profiles/latest/trafficmanager_latest_profile_client.rb +++ b/management/azure_mgmt_traffic_manager/lib/profiles/latest/trafficmanager_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::TrafficManager::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < TrafficManagerClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( diff --git a/management/azure_mgmt_web/lib/profiles/common/configurable.rb b/management/azure_mgmt_web/lib/profiles/common/configurable.rb index 231c6dccfb..5dfed0d57d 100644 --- a/management/azure_mgmt_web/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_web/lib/profiles/common/configurable.rb @@ -2,8 +2,8 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities. +module Azure::Common + # The Azure::Common::Configurable module provides basic configuration for Azure activities. module Configurable # @return [String] Azure tenant id (also known as domain). attr_accessor :tenant_id @@ -25,11 +25,11 @@ module Configurable class << self # - # List of configurable keys for {Azure::ARM::Client}. + # List of configurable keys for {Azure::Common::Client}. # @return [Array] of option keys. # def keys - @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials] + @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings] end end @@ -45,11 +45,14 @@ def configure # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients. # def reset!(options = {}) - Azure::ARM::Configurable.keys.each do |key| - default_value = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.each do |key| + default_value = Azure::Common::Default.options[key] instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end + default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) + self end @@ -64,10 +67,18 @@ def config # def setup_options opts = {} - Azure::ARM::Configurable.keys.map do |key| - opts[key] = Azure::ARM::Default.options[key] + Azure::Common::Configurable.keys.map do |key| + opts[key] = Azure::Common::Default.options[key] end + opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) opts end + + def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) + MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + tenant_id, client_id, client_secret, active_directory_settings)) + end + end end diff --git a/management/azure_mgmt_web/lib/profiles/common/default.rb b/management/azure_mgmt_web/lib/profiles/common/default.rb index b8f5638006..aa6d7c577b 100644 --- a/management/azure_mgmt_web/lib/profiles/common/default.rb +++ b/management/azure_mgmt_web/lib/profiles/common/default.rb @@ -2,8 +2,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -module Azure::ARM - # Default configuration options for {Azure::ARM.Client} +module Azure::Common module Default class << self # @@ -38,16 +37,6 @@ def subscription_id ENV['AZURE_SUBSCRIPTION_ID'] end - # - # Default Azure credentials to authorize HTTP requests made by the service client. - # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client. - # - def credentials - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - # # Default Azure Active Directory Service Settings. # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings. @@ -61,7 +50,7 @@ def active_directory_settings # @return [Hash] Configuration options. # def options - Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}] + Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}] end end end diff --git a/management/azure_mgmt_web/lib/profiles/latest/web_latest_profile_client.rb b/management/azure_mgmt_web/lib/profiles/latest/web_latest_profile_client.rb index 168db91317..dee908fbc0 100644 --- a/management/azure_mgmt_web/lib/profiles/latest/web_latest_profile_client.rb +++ b/management/azure_mgmt_web/lib/profiles/latest/web_latest_profile_client.rb @@ -12,7 +12,7 @@ module Azure::Web::Profiles::Latest::Mgmt # Client class for the Latest profile SDK. # class Client < WebClass - include Azure::ARM::Configurable + include Azure::Common::Configurable def initialize(options = {}) @@ -21,7 +21,7 @@ def initialize(options = {}) def credentials if @credentials.nil? - self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings + self.active_directory_settings ||= Azure::Common::Default.active_directory_settings @credentials = MsRest::TokenCredentials.new( MsRestAzure::ApplicationTokenProvider.new( From d1105755475c1694c76f23df365ed8dc4ed4957b Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 25 Oct 2017 12:03:02 -0700 Subject: [PATCH 3/9] PR Comments to change name of setup_options --- generators/profilegen/src/resources/common/configurable.rb | 2 +- .../profilegen/src/resources/templates/client_template.template | 2 +- .../profilegen/src/resources/templates/module_template.template | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/generators/profilegen/src/resources/common/configurable.rb b/generators/profilegen/src/resources/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/generators/profilegen/src/resources/common/configurable.rb +++ b/generators/profilegen/src/resources/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/generators/profilegen/src/resources/templates/client_template.template b/generators/profilegen/src/resources/templates/client_template.template index 7ae931d863..f62b199623 100644 --- a/generators/profilegen/src/resources/templates/client_template.template +++ b/generators/profilegen/src/resources/templates/client_template.template @@ -42,7 +42,7 @@ module Azure::Profiles::<%= @profile_name %>::Mgmt super(options) <%- else -%> if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/generators/profilegen/src/resources/templates/module_template.template b/generators/profilegen/src/resources/templates/module_template.template index 38441d7f78..83b273125a 100644 --- a/generators/profilegen/src/resources/templates/module_template.template +++ b/generators/profilegen/src/resources/templates/module_template.template @@ -35,7 +35,7 @@ module Azure::Profiles::<%= @profile_name %> <%- if @individual_gem_profile -%> def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end From 1634b0cd43dc6c2827d9d49f52a157da756fb072 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 25 Oct 2017 12:27:37 -0700 Subject: [PATCH 4/9] Regen everything --- azure_sdk/lib/common/configurable.rb | 2 +- azure_sdk/lib/latest/latest_profile_client.rb | 2 +- azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/analysisservices_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/authorization_profile_module.rb | 2 +- .../azure_mgmt_automation/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/automation_profile_module.rb | 2 +- management/azure_mgmt_batch/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/batch_profile_module.rb | 2 +- .../azure_mgmt_billing/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/billing_profile_module.rb | 2 +- management/azure_mgmt_cdn/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/cdn_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/cognitiveservices_profile_module.rb | 2 +- .../azure_mgmt_commerce/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/commerce_profile_module.rb | 2 +- .../azure_mgmt_compute/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/compute_profile_module.rb | 2 +- .../lib/profiles/v2017_03_09/modules/compute_profile_module.rb | 2 +- .../azure_mgmt_consumption/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/consumption_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/containerinstance_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/containerregistry_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/containerservice_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/customerinsights_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/datalakeanalytics_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/datalakestore_profile_module.rb | 2 +- .../azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/devtestlabs_profile_module.rb | 2 +- management/azure_mgmt_dns/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/dns_profile_module.rb | 2 +- .../azure_mgmt_event_grid/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/eventgrid_profile_module.rb | 2 +- .../azure_mgmt_event_hub/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/eventhub_profile_module.rb | 2 +- .../azure_mgmt_features/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/features_profile_module.rb | 2 +- .../lib/profiles/v2017_03_09/modules/features_profile_module.rb | 2 +- management/azure_mgmt_graph/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/graph_profile_module.rb | 2 +- .../azure_mgmt_iot_hub/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/iothub_profile_module.rb | 2 +- .../azure_mgmt_key_vault/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/keyvault_profile_module.rb | 2 +- management/azure_mgmt_links/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/links_profile_module.rb | 2 +- .../lib/profiles/v2017_03_09/modules/links_profile_module.rb | 2 +- management/azure_mgmt_locks/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/locks_profile_module.rb | 2 +- .../lib/profiles/v2017_03_09/modules/locks_profile_module.rb | 2 +- management/azure_mgmt_logic/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/logic_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/machinelearning_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../latest/modules/managedapplications_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../latest/modules/marketplaceordering_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/mediaservices_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/mobileengagement_profile_module.rb | 2 +- .../azure_mgmt_monitor/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/monitor_profile_module.rb | 2 +- .../azure_mgmt_network/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/network_profile_module.rb | 2 +- .../lib/profiles/v2017_03_09/modules/network_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/notificationhubs_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../latest/modules/operationalinsights_profile_module.rb | 2 +- .../azure_mgmt_policy/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/policy_profile_module.rb | 2 +- .../lib/profiles/v2017_03_09/modules/policy_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/powerbiembedded_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/recoveryservices_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../latest/modules/recoveryservicesbackup_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../modules/recoveryservicessiterecovery_profile_module.rb | 2 +- management/azure_mgmt_redis/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/redis_profile_module.rb | 2 +- management/azure_mgmt_relay/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/relay_profile_module.rb | 2 +- .../azure_mgmt_resources/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/resources_profile_module.rb | 2 +- .../profiles/v2017_03_09/modules/resources_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../latest/modules/resourcesmanagement_profile_module.rb | 2 +- .../azure_mgmt_scheduler/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/scheduler_profile_module.rb | 2 +- .../azure_mgmt_search/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/search_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/servermanagement_profile_module.rb | 2 +- .../azure_mgmt_service_bus/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/servicebus_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/servicefabric_profile_module.rb | 2 +- management/azure_mgmt_sql/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/sql_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../latest/modules/storsimple8000series_profile_module.rb | 2 +- .../azure_mgmt_storage/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/storage_profile_module.rb | 2 +- .../lib/profiles/v2017_03_09/modules/storage_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/streamanalytics_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/subscriptions_profile_module.rb | 2 +- .../v2017_03_09/modules/subscriptions_profile_module.rb | 2 +- .../lib/profiles/common/configurable.rb | 2 +- .../profiles/latest/modules/trafficmanager_profile_module.rb | 2 +- management/azure_mgmt_web/lib/profiles/common/configurable.rb | 2 +- .../lib/profiles/latest/modules/web_profile_module.rb | 2 +- 126 files changed, 126 insertions(+), 126 deletions(-) diff --git a/azure_sdk/lib/common/configurable.rb b/azure_sdk/lib/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/azure_sdk/lib/common/configurable.rb +++ b/azure_sdk/lib/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/azure_sdk/lib/latest/latest_profile_client.rb b/azure_sdk/lib/latest/latest_profile_client.rb index cf4b5c81c6..3b4552a1b9 100644 --- a/azure_sdk/lib/latest/latest_profile_client.rb +++ b/azure_sdk/lib/latest/latest_profile_client.rb @@ -74,7 +74,7 @@ class Client def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb b/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb index 6233fb3f29..49904e5bae 100644 --- a/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb +++ b/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb @@ -26,7 +26,7 @@ class Client def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_analysis_services/lib/profiles/latest/modules/analysisservices_profile_module.rb b/management/azure_mgmt_analysis_services/lib/profiles/latest/modules/analysisservices_profile_module.rb index 654a23a564..242959ab2d 100644 --- a/management/azure_mgmt_analysis_services/lib/profiles/latest/modules/analysisservices_profile_module.rb +++ b/management/azure_mgmt_analysis_services/lib/profiles/latest/modules/analysisservices_profile_module.rb @@ -35,7 +35,7 @@ class AnalysisServicesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb b/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_authorization/lib/profiles/latest/modules/authorization_profile_module.rb b/management/azure_mgmt_authorization/lib/profiles/latest/modules/authorization_profile_module.rb index c47bc2be7b..9024fb4173 100644 --- a/management/azure_mgmt_authorization/lib/profiles/latest/modules/authorization_profile_module.rb +++ b/management/azure_mgmt_authorization/lib/profiles/latest/modules/authorization_profile_module.rb @@ -41,7 +41,7 @@ class AuthorizationClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_automation/lib/profiles/common/configurable.rb b/management/azure_mgmt_automation/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_automation/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_automation/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_automation/lib/profiles/latest/modules/automation_profile_module.rb b/management/azure_mgmt_automation/lib/profiles/latest/modules/automation_profile_module.rb index 57d25445a5..369b88e084 100644 --- a/management/azure_mgmt_automation/lib/profiles/latest/modules/automation_profile_module.rb +++ b/management/azure_mgmt_automation/lib/profiles/latest/modules/automation_profile_module.rb @@ -173,7 +173,7 @@ class AutomationClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_batch/lib/profiles/common/configurable.rb b/management/azure_mgmt_batch/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_batch/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_batch/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_batch/lib/profiles/latest/modules/batch_profile_module.rb b/management/azure_mgmt_batch/lib/profiles/latest/modules/batch_profile_module.rb index 2de2ac1008..662da2bb5a 100644 --- a/management/azure_mgmt_batch/lib/profiles/latest/modules/batch_profile_module.rb +++ b/management/azure_mgmt_batch/lib/profiles/latest/modules/batch_profile_module.rb @@ -49,7 +49,7 @@ class BatchClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_billing/lib/profiles/common/configurable.rb b/management/azure_mgmt_billing/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_billing/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_billing/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_billing/lib/profiles/latest/modules/billing_profile_module.rb b/management/azure_mgmt_billing/lib/profiles/latest/modules/billing_profile_module.rb index b658ba02db..86acd56d30 100644 --- a/management/azure_mgmt_billing/lib/profiles/latest/modules/billing_profile_module.rb +++ b/management/azure_mgmt_billing/lib/profiles/latest/modules/billing_profile_module.rb @@ -31,7 +31,7 @@ class BillingClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb b/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_cdn/lib/profiles/latest/modules/cdn_profile_module.rb b/management/azure_mgmt_cdn/lib/profiles/latest/modules/cdn_profile_module.rb index f90b50067d..de174207c7 100644 --- a/management/azure_mgmt_cdn/lib/profiles/latest/modules/cdn_profile_module.rb +++ b/management/azure_mgmt_cdn/lib/profiles/latest/modules/cdn_profile_module.rb @@ -71,7 +71,7 @@ class CDNClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_cognitive_services/lib/profiles/latest/modules/cognitiveservices_profile_module.rb b/management/azure_mgmt_cognitive_services/lib/profiles/latest/modules/cognitiveservices_profile_module.rb index 6f035269f7..87dad0f6e6 100644 --- a/management/azure_mgmt_cognitive_services/lib/profiles/latest/modules/cognitiveservices_profile_module.rb +++ b/management/azure_mgmt_cognitive_services/lib/profiles/latest/modules/cognitiveservices_profile_module.rb @@ -42,7 +42,7 @@ class CognitiveServicesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb b/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_commerce/lib/profiles/latest/modules/commerce_profile_module.rb b/management/azure_mgmt_commerce/lib/profiles/latest/modules/commerce_profile_module.rb index 0cae9c46ec..ea1f5f8ae0 100644 --- a/management/azure_mgmt_commerce/lib/profiles/latest/modules/commerce_profile_module.rb +++ b/management/azure_mgmt_commerce/lib/profiles/latest/modules/commerce_profile_module.rb @@ -31,7 +31,7 @@ class CommerceClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_compute/lib/profiles/common/configurable.rb b/management/azure_mgmt_compute/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_compute/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_compute/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_compute/lib/profiles/latest/modules/compute_profile_module.rb b/management/azure_mgmt_compute/lib/profiles/latest/modules/compute_profile_module.rb index eebb0ca119..f4cc103d29 100644 --- a/management/azure_mgmt_compute/lib/profiles/latest/modules/compute_profile_module.rb +++ b/management/azure_mgmt_compute/lib/profiles/latest/modules/compute_profile_module.rb @@ -200,7 +200,7 @@ class ComputeClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_compute/lib/profiles/v2017_03_09/modules/compute_profile_module.rb b/management/azure_mgmt_compute/lib/profiles/v2017_03_09/modules/compute_profile_module.rb index 1fc92ece89..15a1923695 100644 --- a/management/azure_mgmt_compute/lib/profiles/v2017_03_09/modules/compute_profile_module.rb +++ b/management/azure_mgmt_compute/lib/profiles/v2017_03_09/modules/compute_profile_module.rb @@ -124,7 +124,7 @@ class ComputeClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb b/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_consumption/lib/profiles/latest/modules/consumption_profile_module.rb b/management/azure_mgmt_consumption/lib/profiles/latest/modules/consumption_profile_module.rb index ac08e6f6ca..e5f8180ef2 100644 --- a/management/azure_mgmt_consumption/lib/profiles/latest/modules/consumption_profile_module.rb +++ b/management/azure_mgmt_consumption/lib/profiles/latest/modules/consumption_profile_module.rb @@ -28,7 +28,7 @@ class ConsumptionClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_container_instance/lib/profiles/latest/modules/containerinstance_profile_module.rb b/management/azure_mgmt_container_instance/lib/profiles/latest/modules/containerinstance_profile_module.rb index 382940c985..0d5c922164 100644 --- a/management/azure_mgmt_container_instance/lib/profiles/latest/modules/containerinstance_profile_module.rb +++ b/management/azure_mgmt_container_instance/lib/profiles/latest/modules/containerinstance_profile_module.rb @@ -41,7 +41,7 @@ class ContainerInstanceClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_container_registry/lib/profiles/latest/modules/containerregistry_profile_module.rb b/management/azure_mgmt_container_registry/lib/profiles/latest/modules/containerregistry_profile_module.rb index 8d1769babf..e178b2d311 100644 --- a/management/azure_mgmt_container_registry/lib/profiles/latest/modules/containerregistry_profile_module.rb +++ b/management/azure_mgmt_container_registry/lib/profiles/latest/modules/containerregistry_profile_module.rb @@ -63,7 +63,7 @@ class ContainerRegistryClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_container_service/lib/profiles/latest/modules/containerservice_profile_module.rb b/management/azure_mgmt_container_service/lib/profiles/latest/modules/containerservice_profile_module.rb index 7c34d6a264..cdc8b0fedb 100644 --- a/management/azure_mgmt_container_service/lib/profiles/latest/modules/containerservice_profile_module.rb +++ b/management/azure_mgmt_container_service/lib/profiles/latest/modules/containerservice_profile_module.rb @@ -34,7 +34,7 @@ class ContainerServiceClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb b/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_customer_insights/lib/profiles/latest/modules/customerinsights_profile_module.rb b/management/azure_mgmt_customer_insights/lib/profiles/latest/modules/customerinsights_profile_module.rb index e953e880cb..ad61f9fd0c 100644 --- a/management/azure_mgmt_customer_insights/lib/profiles/latest/modules/customerinsights_profile_module.rb +++ b/management/azure_mgmt_customer_insights/lib/profiles/latest/modules/customerinsights_profile_module.rb @@ -138,7 +138,7 @@ class CustomerInsightsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb b/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_datalake_analytics/lib/profiles/latest/modules/datalakeanalytics_profile_module.rb b/management/azure_mgmt_datalake_analytics/lib/profiles/latest/modules/datalakeanalytics_profile_module.rb index 7c2f34d90b..c6b1dc39a5 100644 --- a/management/azure_mgmt_datalake_analytics/lib/profiles/latest/modules/datalakeanalytics_profile_module.rb +++ b/management/azure_mgmt_datalake_analytics/lib/profiles/latest/modules/datalakeanalytics_profile_module.rb @@ -54,7 +54,7 @@ class DataLakeAnalyticsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb b/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_datalake_store/lib/profiles/latest/modules/datalakestore_profile_module.rb b/management/azure_mgmt_datalake_store/lib/profiles/latest/modules/datalakestore_profile_module.rb index 8fff546bf8..5ea35394cf 100644 --- a/management/azure_mgmt_datalake_store/lib/profiles/latest/modules/datalakestore_profile_module.rb +++ b/management/azure_mgmt_datalake_store/lib/profiles/latest/modules/datalakestore_profile_module.rb @@ -47,7 +47,7 @@ class DataLakeStoreClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb b/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_devtestlabs/lib/profiles/latest/modules/devtestlabs_profile_module.rb b/management/azure_mgmt_devtestlabs/lib/profiles/latest/modules/devtestlabs_profile_module.rb index 9e8ec681aa..18219dd018 100644 --- a/management/azure_mgmt_devtestlabs/lib/profiles/latest/modules/devtestlabs_profile_module.rb +++ b/management/azure_mgmt_devtestlabs/lib/profiles/latest/modules/devtestlabs_profile_module.rb @@ -188,7 +188,7 @@ class DevTestLabsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_dns/lib/profiles/common/configurable.rb b/management/azure_mgmt_dns/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_dns/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_dns/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_dns/lib/profiles/latest/modules/dns_profile_module.rb b/management/azure_mgmt_dns/lib/profiles/latest/modules/dns_profile_module.rb index b0c44264e7..1bea62421c 100644 --- a/management/azure_mgmt_dns/lib/profiles/latest/modules/dns_profile_module.rb +++ b/management/azure_mgmt_dns/lib/profiles/latest/modules/dns_profile_module.rb @@ -38,7 +38,7 @@ class DnsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb b/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_event_grid/lib/profiles/latest/modules/eventgrid_profile_module.rb b/management/azure_mgmt_event_grid/lib/profiles/latest/modules/eventgrid_profile_module.rb index 15272bfe8c..4720c5ab15 100644 --- a/management/azure_mgmt_event_grid/lib/profiles/latest/modules/eventgrid_profile_module.rb +++ b/management/azure_mgmt_event_grid/lib/profiles/latest/modules/eventgrid_profile_module.rb @@ -47,7 +47,7 @@ class EventGridClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb b/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_event_hub/lib/profiles/latest/modules/eventhub_profile_module.rb b/management/azure_mgmt_event_hub/lib/profiles/latest/modules/eventhub_profile_module.rb index 4085fed65a..88366e4161 100644 --- a/management/azure_mgmt_event_hub/lib/profiles/latest/modules/eventhub_profile_module.rb +++ b/management/azure_mgmt_event_hub/lib/profiles/latest/modules/eventhub_profile_module.rb @@ -54,7 +54,7 @@ class EventHubClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_features/lib/profiles/common/configurable.rb b/management/azure_mgmt_features/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_features/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_features/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_features/lib/profiles/latest/modules/features_profile_module.rb b/management/azure_mgmt_features/lib/profiles/latest/modules/features_profile_module.rb index bcdbeb5910..e12603bc44 100644 --- a/management/azure_mgmt_features/lib/profiles/latest/modules/features_profile_module.rb +++ b/management/azure_mgmt_features/lib/profiles/latest/modules/features_profile_module.rb @@ -21,7 +21,7 @@ class FeaturesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_features/lib/profiles/v2017_03_09/modules/features_profile_module.rb b/management/azure_mgmt_features/lib/profiles/v2017_03_09/modules/features_profile_module.rb index b95ef9f20a..a86315adde 100644 --- a/management/azure_mgmt_features/lib/profiles/v2017_03_09/modules/features_profile_module.rb +++ b/management/azure_mgmt_features/lib/profiles/v2017_03_09/modules/features_profile_module.rb @@ -21,7 +21,7 @@ class FeaturesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_graph/lib/profiles/common/configurable.rb b/management/azure_mgmt_graph/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_graph/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_graph/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_graph/lib/profiles/latest/modules/graph_profile_module.rb b/management/azure_mgmt_graph/lib/profiles/latest/modules/graph_profile_module.rb index 338819bf9d..68c2da5bb3 100644 --- a/management/azure_mgmt_graph/lib/profiles/latest/modules/graph_profile_module.rb +++ b/management/azure_mgmt_graph/lib/profiles/latest/modules/graph_profile_module.rb @@ -62,7 +62,7 @@ class GraphClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb b/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_iot_hub/lib/profiles/latest/modules/iothub_profile_module.rb b/management/azure_mgmt_iot_hub/lib/profiles/latest/modules/iothub_profile_module.rb index 2239f3678b..30ad6e959f 100644 --- a/management/azure_mgmt_iot_hub/lib/profiles/latest/modules/iothub_profile_module.rb +++ b/management/azure_mgmt_iot_hub/lib/profiles/latest/modules/iothub_profile_module.rb @@ -78,7 +78,7 @@ class IotHubClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb b/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_key_vault/lib/profiles/latest/modules/keyvault_profile_module.rb b/management/azure_mgmt_key_vault/lib/profiles/latest/modules/keyvault_profile_module.rb index e85cbc1e5f..0f3f52b8da 100644 --- a/management/azure_mgmt_key_vault/lib/profiles/latest/modules/keyvault_profile_module.rb +++ b/management/azure_mgmt_key_vault/lib/profiles/latest/modules/keyvault_profile_module.rb @@ -36,7 +36,7 @@ class KeyVaultClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_links/lib/profiles/common/configurable.rb b/management/azure_mgmt_links/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_links/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_links/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_links/lib/profiles/latest/modules/links_profile_module.rb b/management/azure_mgmt_links/lib/profiles/latest/modules/links_profile_module.rb index edb33276fa..abbf25588b 100644 --- a/management/azure_mgmt_links/lib/profiles/latest/modules/links_profile_module.rb +++ b/management/azure_mgmt_links/lib/profiles/latest/modules/links_profile_module.rb @@ -23,7 +23,7 @@ class LinksClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_links/lib/profiles/v2017_03_09/modules/links_profile_module.rb b/management/azure_mgmt_links/lib/profiles/v2017_03_09/modules/links_profile_module.rb index 5990ce3969..44f8b7a6c8 100644 --- a/management/azure_mgmt_links/lib/profiles/v2017_03_09/modules/links_profile_module.rb +++ b/management/azure_mgmt_links/lib/profiles/v2017_03_09/modules/links_profile_module.rb @@ -23,7 +23,7 @@ class LinksClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_locks/lib/profiles/common/configurable.rb b/management/azure_mgmt_locks/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_locks/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_locks/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_locks/lib/profiles/latest/modules/locks_profile_module.rb b/management/azure_mgmt_locks/lib/profiles/latest/modules/locks_profile_module.rb index 3353b8e6ed..9804c0656c 100644 --- a/management/azure_mgmt_locks/lib/profiles/latest/modules/locks_profile_module.rb +++ b/management/azure_mgmt_locks/lib/profiles/latest/modules/locks_profile_module.rb @@ -22,7 +22,7 @@ class LocksClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_locks/lib/profiles/v2017_03_09/modules/locks_profile_module.rb b/management/azure_mgmt_locks/lib/profiles/v2017_03_09/modules/locks_profile_module.rb index 1e07ca5d8a..8c25f06fba 100644 --- a/management/azure_mgmt_locks/lib/profiles/v2017_03_09/modules/locks_profile_module.rb +++ b/management/azure_mgmt_locks/lib/profiles/v2017_03_09/modules/locks_profile_module.rb @@ -21,7 +21,7 @@ class LocksClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_logic/lib/profiles/common/configurable.rb b/management/azure_mgmt_logic/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_logic/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_logic/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_logic/lib/profiles/latest/modules/logic_profile_module.rb b/management/azure_mgmt_logic/lib/profiles/latest/modules/logic_profile_module.rb index 3e6bfc1454..f183c5197c 100644 --- a/management/azure_mgmt_logic/lib/profiles/latest/modules/logic_profile_module.rb +++ b/management/azure_mgmt_logic/lib/profiles/latest/modules/logic_profile_module.rb @@ -165,7 +165,7 @@ class LogicClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb b/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_machine_learning/lib/profiles/latest/modules/machinelearning_profile_module.rb b/management/azure_mgmt_machine_learning/lib/profiles/latest/modules/machinelearning_profile_module.rb index 141f2b5d5a..a347e430ef 100644 --- a/management/azure_mgmt_machine_learning/lib/profiles/latest/modules/machinelearning_profile_module.rb +++ b/management/azure_mgmt_machine_learning/lib/profiles/latest/modules/machinelearning_profile_module.rb @@ -55,7 +55,7 @@ class MachineLearningClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb b/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_managed_applications/lib/profiles/latest/modules/managedapplications_profile_module.rb b/management/azure_mgmt_managed_applications/lib/profiles/latest/modules/managedapplications_profile_module.rb index d5e80a657c..64b096fbeb 100644 --- a/management/azure_mgmt_managed_applications/lib/profiles/latest/modules/managedapplications_profile_module.rb +++ b/management/azure_mgmt_managed_applications/lib/profiles/latest/modules/managedapplications_profile_module.rb @@ -37,7 +37,7 @@ class ManagedApplicationsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb b/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/modules/marketplaceordering_profile_module.rb b/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/modules/marketplaceordering_profile_module.rb index d4535ff2ed..fe1045a9a6 100644 --- a/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/modules/marketplaceordering_profile_module.rb +++ b/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/modules/marketplaceordering_profile_module.rb @@ -26,7 +26,7 @@ class MarketplaceOrderingClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_media_services/lib/profiles/latest/modules/mediaservices_profile_module.rb b/management/azure_mgmt_media_services/lib/profiles/latest/modules/mediaservices_profile_module.rb index 61d07d44d1..a74b49be3a 100644 --- a/management/azure_mgmt_media_services/lib/profiles/latest/modules/mediaservices_profile_module.rb +++ b/management/azure_mgmt_media_services/lib/profiles/latest/modules/mediaservices_profile_module.rb @@ -37,7 +37,7 @@ class MediaServicesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb b/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_mobile_engagement/lib/profiles/latest/modules/mobileengagement_profile_module.rb b/management/azure_mgmt_mobile_engagement/lib/profiles/latest/modules/mobileengagement_profile_module.rb index 8ba27d33aa..8ad26213f1 100644 --- a/management/azure_mgmt_mobile_engagement/lib/profiles/latest/modules/mobileengagement_profile_module.rb +++ b/management/azure_mgmt_mobile_engagement/lib/profiles/latest/modules/mobileengagement_profile_module.rb @@ -113,7 +113,7 @@ class MobileEngagementClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb b/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_monitor/lib/profiles/latest/modules/monitor_profile_module.rb b/management/azure_mgmt_monitor/lib/profiles/latest/modules/monitor_profile_module.rb index 07310e5fd4..1cb7c7a061 100644 --- a/management/azure_mgmt_monitor/lib/profiles/latest/modules/monitor_profile_module.rb +++ b/management/azure_mgmt_monitor/lib/profiles/latest/modules/monitor_profile_module.rb @@ -96,7 +96,7 @@ class MonitorClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_network/lib/profiles/common/configurable.rb b/management/azure_mgmt_network/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_network/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_network/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_network/lib/profiles/latest/modules/network_profile_module.rb b/management/azure_mgmt_network/lib/profiles/latest/modules/network_profile_module.rb index 3428142cb8..1ad6c68154 100644 --- a/management/azure_mgmt_network/lib/profiles/latest/modules/network_profile_module.rb +++ b/management/azure_mgmt_network/lib/profiles/latest/modules/network_profile_module.rb @@ -318,7 +318,7 @@ class NetworkClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_network/lib/profiles/v2017_03_09/modules/network_profile_module.rb b/management/azure_mgmt_network/lib/profiles/v2017_03_09/modules/network_profile_module.rb index 80cc3d0078..854056a670 100644 --- a/management/azure_mgmt_network/lib/profiles/v2017_03_09/modules/network_profile_module.rb +++ b/management/azure_mgmt_network/lib/profiles/v2017_03_09/modules/network_profile_module.rb @@ -153,7 +153,7 @@ class NetworkClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb b/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_notification_hubs/lib/profiles/latest/modules/notificationhubs_profile_module.rb b/management/azure_mgmt_notification_hubs/lib/profiles/latest/modules/notificationhubs_profile_module.rb index f529a84afa..0080500f37 100644 --- a/management/azure_mgmt_notification_hubs/lib/profiles/latest/modules/notificationhubs_profile_module.rb +++ b/management/azure_mgmt_notification_hubs/lib/profiles/latest/modules/notificationhubs_profile_module.rb @@ -51,7 +51,7 @@ class NotificationHubsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb b/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_operational_insights/lib/profiles/latest/modules/operationalinsights_profile_module.rb b/management/azure_mgmt_operational_insights/lib/profiles/latest/modules/operationalinsights_profile_module.rb index e193fb2fca..aa925ad201 100644 --- a/management/azure_mgmt_operational_insights/lib/profiles/latest/modules/operationalinsights_profile_module.rb +++ b/management/azure_mgmt_operational_insights/lib/profiles/latest/modules/operationalinsights_profile_module.rb @@ -62,7 +62,7 @@ class OperationalInsightsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_policy/lib/profiles/common/configurable.rb b/management/azure_mgmt_policy/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_policy/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_policy/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_policy/lib/profiles/latest/modules/policy_profile_module.rb b/management/azure_mgmt_policy/lib/profiles/latest/modules/policy_profile_module.rb index fd845bfbe0..3b20605994 100644 --- a/management/azure_mgmt_policy/lib/profiles/latest/modules/policy_profile_module.rb +++ b/management/azure_mgmt_policy/lib/profiles/latest/modules/policy_profile_module.rb @@ -31,7 +31,7 @@ class PolicyClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_policy/lib/profiles/v2017_03_09/modules/policy_profile_module.rb b/management/azure_mgmt_policy/lib/profiles/v2017_03_09/modules/policy_profile_module.rb index 41d25999b4..5d0c2d3c53 100644 --- a/management/azure_mgmt_policy/lib/profiles/v2017_03_09/modules/policy_profile_module.rb +++ b/management/azure_mgmt_policy/lib/profiles/v2017_03_09/modules/policy_profile_module.rb @@ -24,7 +24,7 @@ class PolicyClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb b/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/modules/powerbiembedded_profile_module.rb b/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/modules/powerbiembedded_profile_module.rb index 9d213a281e..2c1570fb4d 100644 --- a/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/modules/powerbiembedded_profile_module.rb +++ b/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/modules/powerbiembedded_profile_module.rb @@ -38,7 +38,7 @@ class PowerBiEmbeddedClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_recovery_services/lib/profiles/latest/modules/recoveryservices_profile_module.rb b/management/azure_mgmt_recovery_services/lib/profiles/latest/modules/recoveryservices_profile_module.rb index 243e9948cd..a6f404f830 100644 --- a/management/azure_mgmt_recovery_services/lib/profiles/latest/modules/recoveryservices_profile_module.rb +++ b/management/azure_mgmt_recovery_services/lib/profiles/latest/modules/recoveryservices_profile_module.rb @@ -64,7 +64,7 @@ class RecoveryServicesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/modules/recoveryservicesbackup_profile_module.rb b/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/modules/recoveryservicesbackup_profile_module.rb index 7ee0ecceb8..baceb10e6a 100644 --- a/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/modules/recoveryservicesbackup_profile_module.rb +++ b/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/modules/recoveryservicesbackup_profile_module.rb @@ -209,7 +209,7 @@ class RecoveryServicesBackupClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/modules/recoveryservicessiterecovery_profile_module.rb b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/modules/recoveryservicessiterecovery_profile_module.rb index d26b4e6f06..c0060b88fb 100644 --- a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/modules/recoveryservicessiterecovery_profile_module.rb +++ b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/modules/recoveryservicessiterecovery_profile_module.rb @@ -362,7 +362,7 @@ class RecoveryServicesSiteRecoveryClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_redis/lib/profiles/common/configurable.rb b/management/azure_mgmt_redis/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_redis/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_redis/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_redis/lib/profiles/latest/modules/redis_profile_module.rb b/management/azure_mgmt_redis/lib/profiles/latest/modules/redis_profile_module.rb index 253f893022..59de1b4291 100644 --- a/management/azure_mgmt_redis/lib/profiles/latest/modules/redis_profile_module.rb +++ b/management/azure_mgmt_redis/lib/profiles/latest/modules/redis_profile_module.rb @@ -54,7 +54,7 @@ class RedisClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_relay/lib/profiles/common/configurable.rb b/management/azure_mgmt_relay/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_relay/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_relay/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_relay/lib/profiles/latest/modules/relay_profile_module.rb b/management/azure_mgmt_relay/lib/profiles/latest/modules/relay_profile_module.rb index 959642454b..8d21ebe670 100644 --- a/management/azure_mgmt_relay/lib/profiles/latest/modules/relay_profile_module.rb +++ b/management/azure_mgmt_relay/lib/profiles/latest/modules/relay_profile_module.rb @@ -48,7 +48,7 @@ class RelayClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_resources/lib/profiles/common/configurable.rb b/management/azure_mgmt_resources/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_resources/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_resources/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_resources/lib/profiles/latest/modules/resources_profile_module.rb b/management/azure_mgmt_resources/lib/profiles/latest/modules/resources_profile_module.rb index 586e8d6a8e..a6395fe7a1 100644 --- a/management/azure_mgmt_resources/lib/profiles/latest/modules/resources_profile_module.rb +++ b/management/azure_mgmt_resources/lib/profiles/latest/modules/resources_profile_module.rb @@ -70,7 +70,7 @@ class ResourcesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_resources/lib/profiles/v2017_03_09/modules/resources_profile_module.rb b/management/azure_mgmt_resources/lib/profiles/v2017_03_09/modules/resources_profile_module.rb index 521cb0340d..2b85721178 100644 --- a/management/azure_mgmt_resources/lib/profiles/v2017_03_09/modules/resources_profile_module.rb +++ b/management/azure_mgmt_resources/lib/profiles/v2017_03_09/modules/resources_profile_module.rb @@ -69,7 +69,7 @@ class ResourcesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb b/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_resources_management/lib/profiles/latest/modules/resourcesmanagement_profile_module.rb b/management/azure_mgmt_resources_management/lib/profiles/latest/modules/resourcesmanagement_profile_module.rb index 6d43397b6a..9ef276599b 100644 --- a/management/azure_mgmt_resources_management/lib/profiles/latest/modules/resourcesmanagement_profile_module.rb +++ b/management/azure_mgmt_resources_management/lib/profiles/latest/modules/resourcesmanagement_profile_module.rb @@ -33,7 +33,7 @@ class ResourcesManagementClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb b/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_scheduler/lib/profiles/latest/modules/scheduler_profile_module.rb b/management/azure_mgmt_scheduler/lib/profiles/latest/modules/scheduler_profile_module.rb index 901d879aa6..827bc71195 100644 --- a/management/azure_mgmt_scheduler/lib/profiles/latest/modules/scheduler_profile_module.rb +++ b/management/azure_mgmt_scheduler/lib/profiles/latest/modules/scheduler_profile_module.rb @@ -64,7 +64,7 @@ class SchedulerClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_search/lib/profiles/common/configurable.rb b/management/azure_mgmt_search/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_search/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_search/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_search/lib/profiles/latest/modules/search_profile_module.rb b/management/azure_mgmt_search/lib/profiles/latest/modules/search_profile_module.rb index baca733ad4..ba1095f374 100644 --- a/management/azure_mgmt_search/lib/profiles/latest/modules/search_profile_module.rb +++ b/management/azure_mgmt_search/lib/profiles/latest/modules/search_profile_module.rb @@ -34,7 +34,7 @@ class SearchClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb b/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_server_management/lib/profiles/latest/modules/servermanagement_profile_module.rb b/management/azure_mgmt_server_management/lib/profiles/latest/modules/servermanagement_profile_module.rb index 162292f14d..6baa117273 100644 --- a/management/azure_mgmt_server_management/lib/profiles/latest/modules/servermanagement_profile_module.rb +++ b/management/azure_mgmt_server_management/lib/profiles/latest/modules/servermanagement_profile_module.rb @@ -51,7 +51,7 @@ class ServerManagementClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb b/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_service_bus/lib/profiles/latest/modules/servicebus_profile_module.rb b/management/azure_mgmt_service_bus/lib/profiles/latest/modules/servicebus_profile_module.rb index 84cac87b1f..84d93ad05d 100644 --- a/management/azure_mgmt_service_bus/lib/profiles/latest/modules/servicebus_profile_module.rb +++ b/management/azure_mgmt_service_bus/lib/profiles/latest/modules/servicebus_profile_module.rb @@ -77,7 +77,7 @@ class ServiceBusClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb b/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_service_fabric/lib/profiles/latest/modules/servicefabric_profile_module.rb b/management/azure_mgmt_service_fabric/lib/profiles/latest/modules/servicefabric_profile_module.rb index e8f8388e3f..c261e8b447 100644 --- a/management/azure_mgmt_service_fabric/lib/profiles/latest/modules/servicefabric_profile_module.rb +++ b/management/azure_mgmt_service_fabric/lib/profiles/latest/modules/servicefabric_profile_module.rb @@ -45,7 +45,7 @@ class ServiceFabricClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_sql/lib/profiles/common/configurable.rb b/management/azure_mgmt_sql/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_sql/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_sql/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_sql/lib/profiles/latest/modules/sql_profile_module.rb b/management/azure_mgmt_sql/lib/profiles/latest/modules/sql_profile_module.rb index 6857d94484..bb664d887a 100644 --- a/management/azure_mgmt_sql/lib/profiles/latest/modules/sql_profile_module.rb +++ b/management/azure_mgmt_sql/lib/profiles/latest/modules/sql_profile_module.rb @@ -264,7 +264,7 @@ class SQLClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb b/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/modules/storsimple8000series_profile_module.rb b/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/modules/storsimple8000series_profile_module.rb index b5d43a3f70..cbf2bcd02b 100644 --- a/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/modules/storsimple8000series_profile_module.rb +++ b/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/modules/storsimple8000series_profile_module.rb @@ -192,7 +192,7 @@ class StorSimple8000SeriesClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_storage/lib/profiles/common/configurable.rb b/management/azure_mgmt_storage/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_storage/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_storage/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_storage/lib/profiles/latest/modules/storage_profile_module.rb b/management/azure_mgmt_storage/lib/profiles/latest/modules/storage_profile_module.rb index e8cb1a05d4..ca37a0e40c 100644 --- a/management/azure_mgmt_storage/lib/profiles/latest/modules/storage_profile_module.rb +++ b/management/azure_mgmt_storage/lib/profiles/latest/modules/storage_profile_module.rb @@ -78,7 +78,7 @@ class StorageClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_storage/lib/profiles/v2017_03_09/modules/storage_profile_module.rb b/management/azure_mgmt_storage/lib/profiles/v2017_03_09/modules/storage_profile_module.rb index e274140394..8adad55eb3 100644 --- a/management/azure_mgmt_storage/lib/profiles/v2017_03_09/modules/storage_profile_module.rb +++ b/management/azure_mgmt_storage/lib/profiles/v2017_03_09/modules/storage_profile_module.rb @@ -38,7 +38,7 @@ class StorageClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb b/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_stream_analytics/lib/profiles/latest/modules/streamanalytics_profile_module.rb b/management/azure_mgmt_stream_analytics/lib/profiles/latest/modules/streamanalytics_profile_module.rb index 7dab6660ee..66802b08c5 100644 --- a/management/azure_mgmt_stream_analytics/lib/profiles/latest/modules/streamanalytics_profile_module.rb +++ b/management/azure_mgmt_stream_analytics/lib/profiles/latest/modules/streamanalytics_profile_module.rb @@ -96,7 +96,7 @@ class StreamAnalyticsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb b/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_subscriptions/lib/profiles/latest/modules/subscriptions_profile_module.rb b/management/azure_mgmt_subscriptions/lib/profiles/latest/modules/subscriptions_profile_module.rb index 7caaf86d18..7cf622383f 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/latest/modules/subscriptions_profile_module.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/latest/modules/subscriptions_profile_module.rb @@ -28,7 +28,7 @@ class SubscriptionsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/modules/subscriptions_profile_module.rb b/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/modules/subscriptions_profile_module.rb index 10ee87a97e..50a2343350 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/modules/subscriptions_profile_module.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/modules/subscriptions_profile_module.rb @@ -28,7 +28,7 @@ class SubscriptionsClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb b/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_traffic_manager/lib/profiles/latest/modules/trafficmanager_profile_module.rb b/management/azure_mgmt_traffic_manager/lib/profiles/latest/modules/trafficmanager_profile_module.rb index 3fb4ba15be..8f746791a3 100644 --- a/management/azure_mgmt_traffic_manager/lib/profiles/latest/modules/trafficmanager_profile_module.rb +++ b/management/azure_mgmt_traffic_manager/lib/profiles/latest/modules/trafficmanager_profile_module.rb @@ -46,7 +46,7 @@ class TrafficManagerClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end diff --git a/management/azure_mgmt_web/lib/profiles/common/configurable.rb b/management/azure_mgmt_web/lib/profiles/common/configurable.rb index 5dfed0d57d..792897cb8a 100644 --- a/management/azure_mgmt_web/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_web/lib/profiles/common/configurable.rb @@ -65,7 +65,7 @@ def config # # configures configurable options to default values # - def setup_options + def setup_default_options opts = {} Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] diff --git a/management/azure_mgmt_web/lib/profiles/latest/modules/web_profile_module.rb b/management/azure_mgmt_web/lib/profiles/latest/modules/web_profile_module.rb index ec62091185..de2c9520d2 100644 --- a/management/azure_mgmt_web/lib/profiles/latest/modules/web_profile_module.rb +++ b/management/azure_mgmt_web/lib/profiles/latest/modules/web_profile_module.rb @@ -299,7 +299,7 @@ class WebClass def initialize(options = {}) if options.is_a?(Hash) && options.length == 0 - @options = setup_options + @options = setup_default_options else @options = options end From 7f3f5cc89596530f8f66bad2eae9143653255e80 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 26 Oct 2017 12:00:48 -0700 Subject: [PATCH 5/9] PR Comments --- README.md | 51 +++++++++++++++---- .../src/resources/common/configurable.rb | 20 ++++---- .../templates/client_template.template | 10 ---- 3 files changed, 53 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 8f7b256e6e..6760563d62 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,41 @@ Note: x64 Ruby for Windows is known to have some compatibility issues. # Getting Started with Azure Resource Manager Usage (Preview) +## Prerequisite + +In order to use the Azure SDK, you must supply the following values to the Azure SDK: + +* Tenant Id +* Client Id +* Subscription Id +* Client Secret + +You could pass the above values in the following ways: + +### Option 1 - Environment Variables +You can set the (above) values using the following environment variables: + +* AZURE_TENANT_ID +* AZURE_CLIENT_ID +* AZURE_SUBSCRIPTION_ID +* AZURE_CLIENT_SECRET + +### Option 2 - Options Hash +You can set the (above) values using the options hash: + +```ruby +options = { + tenant_id: 'YOUR TENANT ID', + client_id: 'YOUR CLIENT ID', + client_secret: 'YOUR CLIENT SECRET', + subscription_id: 'YOUR SUBSCRIPTION ID' +} +``` + +### Option 3 - Combination of Environment Variables & Options Hash +You can set the (above) values using a combination of environment variables and options hash. The values mentioned in the options hash will take precedence over the environment variables. + + ## Install the rubygem packages You can install the azure rubygem packages directly. @@ -218,8 +253,7 @@ purchase_plan_obj = Azure::Compute::Profiles::Latest::Mgmt::Models::PurchasePlan ## Usage of Individual gem using using specific api-version -In the previous section, we used the profile associated with individual gem. In the current section, we could use the -version directly. +In the previous section, we used the profile associated with individual gem. In the current section, we could use the version directly. ### Install @@ -234,16 +268,15 @@ The following lines should be used to instantiate a profile client: ```ruby # Provide credentials -options = { - tenant_id: ENV['AZURE_TENANT_ID'], - client_id: ENV['AZURE_CLIENT_ID'], - client_secret: ENV['AZURE_CLIENT_SECRET'], - subscription_id: ENV['AZURE_SUBSCRIPTION_ID'] -} +provider = MsRestAzure::ApplicationTokenProvider.new( + ENV['AZURE_TENANT_ID'], + ENV['AZURE_CLIENT_ID'], + ENV['AZURE_CLIENT_SECRET']) +credentials = MsRest::TokenCredentials.new(provider) # Target client for 2016_03_30 version of Compute compute_client = Azure::Compute::Mgmt::V2016_03_30::ComputeManagementClient.new(credentials) -compute_client.subscription_id = subscription_id +compute_client.subscription_id = ENV['AZURE_SUBSCRIPTION_ID'] ``` The compute client could be used to access operations and models: diff --git a/generators/profilegen/src/resources/common/configurable.rb b/generators/profilegen/src/resources/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/generators/profilegen/src/resources/common/configurable.rb +++ b/generators/profilegen/src/resources/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/generators/profilegen/src/resources/templates/client_template.template b/generators/profilegen/src/resources/templates/client_template.template index f62b199623..aa1e1c64bb 100644 --- a/generators/profilegen/src/resources/templates/client_template.template +++ b/generators/profilegen/src/resources/templates/client_template.template @@ -55,15 +55,5 @@ module Azure::Profiles::<%= @profile_name %>::Mgmt <%- end -%> end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end From 511f77467fec492bfbd3d80fc75b0d4c958857c9 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 26 Oct 2017 12:29:11 -0700 Subject: [PATCH 6/9] Regen everything --- azure_sdk/lib/common/configurable.rb | 20 ++++++++++--------- azure_sdk/lib/latest/latest_profile_client.rb | 10 ---------- .../v2017_03_09/v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../analysisservices_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../authorization_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../automation_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/batch_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/billing_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/cdn_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...cognitiveservices_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/commerce_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/compute_latest_profile_client.rb | 10 ---------- .../compute_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../consumption_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...containerinstance_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...containerregistry_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../containerservice_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../customerinsights_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...datalakeanalytics_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../datalakestore_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../devtestlabs_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/dns_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/eventgrid_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/eventhub_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/features_latest_profile_client.rb | 10 ---------- .../features_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/graph_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/iothub_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/keyvault_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/links_latest_profile_client.rb | 10 ---------- .../links_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/locks_latest_profile_client.rb | 10 ---------- .../locks_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/logic_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../machinelearning_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...nagedapplications_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...rketplaceordering_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../mediaservices_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../mobileengagement_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/monitor_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/network_latest_profile_client.rb | 10 ---------- .../network_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../notificationhubs_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...erationalinsights_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/policy_latest_profile_client.rb | 10 ---------- .../policy_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../powerbiembedded_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../recoveryservices_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...eryservicesbackup_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...vicessiterecovery_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/redis_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/relay_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/resources_latest_profile_client.rb | 10 ---------- .../resources_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...sourcesmanagement_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/scheduler_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/search_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../servermanagement_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../servicebus_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../servicefabric_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/sql_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- ...rsimple8000series_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/storage_latest_profile_client.rb | 10 ---------- .../storage_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../streamanalytics_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../subscriptions_latest_profile_client.rb | 10 ---------- ...ubscriptions_v2017_03_09_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../trafficmanager_latest_profile_client.rb | 10 ---------- .../lib/profiles/common/configurable.rb | 20 ++++++++++--------- .../latest/web_latest_profile_client.rb | 10 ---------- 126 files changed, 638 insertions(+), 1202 deletions(-) diff --git a/azure_sdk/lib/common/configurable.rb b/azure_sdk/lib/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/azure_sdk/lib/common/configurable.rb +++ b/azure_sdk/lib/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/azure_sdk/lib/latest/latest_profile_client.rb b/azure_sdk/lib/latest/latest_profile_client.rb index 3b4552a1b9..8c30c5f827 100644 --- a/azure_sdk/lib/latest/latest_profile_client.rb +++ b/azure_sdk/lib/latest/latest_profile_client.rb @@ -140,15 +140,5 @@ def initialize(options = {}) @web = Azure::Profiles::Latest::Web::Mgmt::WebClass.new(self) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb b/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb index 49904e5bae..fc348c2c3f 100644 --- a/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb +++ b/azure_sdk/lib/v2017_03_09/v2017_03_09_profile_client.rb @@ -44,15 +44,5 @@ def initialize(options = {}) @subscriptions = Azure::Profiles::V2017_03_09::Subscriptions::Mgmt::SubscriptionsClass.new(self) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_analysis_services/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_analysis_services/lib/profiles/latest/analysisservices_latest_profile_client.rb b/management/azure_mgmt_analysis_services/lib/profiles/latest/analysisservices_latest_profile_client.rb index 4f3f15430c..073ce57845 100644 --- a/management/azure_mgmt_analysis_services/lib/profiles/latest/analysisservices_latest_profile_client.rb +++ b/management/azure_mgmt_analysis_services/lib/profiles/latest/analysisservices_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb b/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_authorization/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_authorization/lib/profiles/latest/authorization_latest_profile_client.rb b/management/azure_mgmt_authorization/lib/profiles/latest/authorization_latest_profile_client.rb index 68a93205fa..e5bc872a3c 100644 --- a/management/azure_mgmt_authorization/lib/profiles/latest/authorization_latest_profile_client.rb +++ b/management/azure_mgmt_authorization/lib/profiles/latest/authorization_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_automation/lib/profiles/common/configurable.rb b/management/azure_mgmt_automation/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_automation/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_automation/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_automation/lib/profiles/latest/automation_latest_profile_client.rb b/management/azure_mgmt_automation/lib/profiles/latest/automation_latest_profile_client.rb index 1f1924267d..fa9ebea461 100644 --- a/management/azure_mgmt_automation/lib/profiles/latest/automation_latest_profile_client.rb +++ b/management/azure_mgmt_automation/lib/profiles/latest/automation_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_batch/lib/profiles/common/configurable.rb b/management/azure_mgmt_batch/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_batch/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_batch/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_batch/lib/profiles/latest/batch_latest_profile_client.rb b/management/azure_mgmt_batch/lib/profiles/latest/batch_latest_profile_client.rb index 29eb2e753c..dcea9ecdc9 100644 --- a/management/azure_mgmt_batch/lib/profiles/latest/batch_latest_profile_client.rb +++ b/management/azure_mgmt_batch/lib/profiles/latest/batch_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_billing/lib/profiles/common/configurable.rb b/management/azure_mgmt_billing/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_billing/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_billing/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_billing/lib/profiles/latest/billing_latest_profile_client.rb b/management/azure_mgmt_billing/lib/profiles/latest/billing_latest_profile_client.rb index 28effe762d..f4e2149890 100644 --- a/management/azure_mgmt_billing/lib/profiles/latest/billing_latest_profile_client.rb +++ b/management/azure_mgmt_billing/lib/profiles/latest/billing_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb b/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_cdn/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_cdn/lib/profiles/latest/cdn_latest_profile_client.rb b/management/azure_mgmt_cdn/lib/profiles/latest/cdn_latest_profile_client.rb index 8636259d3d..f605b4e016 100644 --- a/management/azure_mgmt_cdn/lib/profiles/latest/cdn_latest_profile_client.rb +++ b/management/azure_mgmt_cdn/lib/profiles/latest/cdn_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_cognitive_services/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_cognitive_services/lib/profiles/latest/cognitiveservices_latest_profile_client.rb b/management/azure_mgmt_cognitive_services/lib/profiles/latest/cognitiveservices_latest_profile_client.rb index 13fa68c147..b07146594e 100644 --- a/management/azure_mgmt_cognitive_services/lib/profiles/latest/cognitiveservices_latest_profile_client.rb +++ b/management/azure_mgmt_cognitive_services/lib/profiles/latest/cognitiveservices_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb b/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_commerce/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_commerce/lib/profiles/latest/commerce_latest_profile_client.rb b/management/azure_mgmt_commerce/lib/profiles/latest/commerce_latest_profile_client.rb index 25af12921f..8168009c79 100644 --- a/management/azure_mgmt_commerce/lib/profiles/latest/commerce_latest_profile_client.rb +++ b/management/azure_mgmt_commerce/lib/profiles/latest/commerce_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_compute/lib/profiles/common/configurable.rb b/management/azure_mgmt_compute/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_compute/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_compute/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_compute/lib/profiles/latest/compute_latest_profile_client.rb b/management/azure_mgmt_compute/lib/profiles/latest/compute_latest_profile_client.rb index 5e0059343a..d399917cf3 100644 --- a/management/azure_mgmt_compute/lib/profiles/latest/compute_latest_profile_client.rb +++ b/management/azure_mgmt_compute/lib/profiles/latest/compute_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_compute/lib/profiles/v2017_03_09/compute_v2017_03_09_profile_client.rb b/management/azure_mgmt_compute/lib/profiles/v2017_03_09/compute_v2017_03_09_profile_client.rb index 7fc6e4a380..3f96ed99eb 100644 --- a/management/azure_mgmt_compute/lib/profiles/v2017_03_09/compute_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_compute/lib/profiles/v2017_03_09/compute_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb b/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_consumption/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_consumption/lib/profiles/latest/consumption_latest_profile_client.rb b/management/azure_mgmt_consumption/lib/profiles/latest/consumption_latest_profile_client.rb index c981955331..a0ee788786 100644 --- a/management/azure_mgmt_consumption/lib/profiles/latest/consumption_latest_profile_client.rb +++ b/management/azure_mgmt_consumption/lib/profiles/latest/consumption_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_instance/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_container_instance/lib/profiles/latest/containerinstance_latest_profile_client.rb b/management/azure_mgmt_container_instance/lib/profiles/latest/containerinstance_latest_profile_client.rb index 115bc6477b..e4ca82fe79 100644 --- a/management/azure_mgmt_container_instance/lib/profiles/latest/containerinstance_latest_profile_client.rb +++ b/management/azure_mgmt_container_instance/lib/profiles/latest/containerinstance_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_registry/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_container_registry/lib/profiles/latest/containerregistry_latest_profile_client.rb b/management/azure_mgmt_container_registry/lib/profiles/latest/containerregistry_latest_profile_client.rb index 5938465471..2195400305 100644 --- a/management/azure_mgmt_container_registry/lib/profiles/latest/containerregistry_latest_profile_client.rb +++ b/management/azure_mgmt_container_registry/lib/profiles/latest/containerregistry_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb b/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_container_service/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_container_service/lib/profiles/latest/containerservice_latest_profile_client.rb b/management/azure_mgmt_container_service/lib/profiles/latest/containerservice_latest_profile_client.rb index 5237c13563..cbcadd6b92 100644 --- a/management/azure_mgmt_container_service/lib/profiles/latest/containerservice_latest_profile_client.rb +++ b/management/azure_mgmt_container_service/lib/profiles/latest/containerservice_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb b/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_customer_insights/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_customer_insights/lib/profiles/latest/customerinsights_latest_profile_client.rb b/management/azure_mgmt_customer_insights/lib/profiles/latest/customerinsights_latest_profile_client.rb index 1150e25c48..092c12ea18 100644 --- a/management/azure_mgmt_customer_insights/lib/profiles/latest/customerinsights_latest_profile_client.rb +++ b/management/azure_mgmt_customer_insights/lib/profiles/latest/customerinsights_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb b/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_datalake_analytics/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_datalake_analytics/lib/profiles/latest/datalakeanalytics_latest_profile_client.rb b/management/azure_mgmt_datalake_analytics/lib/profiles/latest/datalakeanalytics_latest_profile_client.rb index a9a180e7dd..04081ffc86 100644 --- a/management/azure_mgmt_datalake_analytics/lib/profiles/latest/datalakeanalytics_latest_profile_client.rb +++ b/management/azure_mgmt_datalake_analytics/lib/profiles/latest/datalakeanalytics_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb b/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_datalake_store/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_datalake_store/lib/profiles/latest/datalakestore_latest_profile_client.rb b/management/azure_mgmt_datalake_store/lib/profiles/latest/datalakestore_latest_profile_client.rb index 7a2c62e59c..9a0e9a52e9 100644 --- a/management/azure_mgmt_datalake_store/lib/profiles/latest/datalakestore_latest_profile_client.rb +++ b/management/azure_mgmt_datalake_store/lib/profiles/latest/datalakestore_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb b/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_devtestlabs/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_devtestlabs/lib/profiles/latest/devtestlabs_latest_profile_client.rb b/management/azure_mgmt_devtestlabs/lib/profiles/latest/devtestlabs_latest_profile_client.rb index 0631183018..b45cf1dc3f 100644 --- a/management/azure_mgmt_devtestlabs/lib/profiles/latest/devtestlabs_latest_profile_client.rb +++ b/management/azure_mgmt_devtestlabs/lib/profiles/latest/devtestlabs_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_dns/lib/profiles/common/configurable.rb b/management/azure_mgmt_dns/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_dns/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_dns/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_dns/lib/profiles/latest/dns_latest_profile_client.rb b/management/azure_mgmt_dns/lib/profiles/latest/dns_latest_profile_client.rb index b2363c1107..f654247145 100644 --- a/management/azure_mgmt_dns/lib/profiles/latest/dns_latest_profile_client.rb +++ b/management/azure_mgmt_dns/lib/profiles/latest/dns_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb b/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_event_grid/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_event_grid/lib/profiles/latest/eventgrid_latest_profile_client.rb b/management/azure_mgmt_event_grid/lib/profiles/latest/eventgrid_latest_profile_client.rb index d55a0517d3..25d836188b 100644 --- a/management/azure_mgmt_event_grid/lib/profiles/latest/eventgrid_latest_profile_client.rb +++ b/management/azure_mgmt_event_grid/lib/profiles/latest/eventgrid_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb b/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_event_hub/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_event_hub/lib/profiles/latest/eventhub_latest_profile_client.rb b/management/azure_mgmt_event_hub/lib/profiles/latest/eventhub_latest_profile_client.rb index f7b8f951e9..40dd77bc50 100644 --- a/management/azure_mgmt_event_hub/lib/profiles/latest/eventhub_latest_profile_client.rb +++ b/management/azure_mgmt_event_hub/lib/profiles/latest/eventhub_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_features/lib/profiles/common/configurable.rb b/management/azure_mgmt_features/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_features/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_features/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_features/lib/profiles/latest/features_latest_profile_client.rb b/management/azure_mgmt_features/lib/profiles/latest/features_latest_profile_client.rb index 13481de7da..ee6fb1ecd1 100644 --- a/management/azure_mgmt_features/lib/profiles/latest/features_latest_profile_client.rb +++ b/management/azure_mgmt_features/lib/profiles/latest/features_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_features/lib/profiles/v2017_03_09/features_v2017_03_09_profile_client.rb b/management/azure_mgmt_features/lib/profiles/v2017_03_09/features_v2017_03_09_profile_client.rb index c00f3dd21a..1c73533308 100644 --- a/management/azure_mgmt_features/lib/profiles/v2017_03_09/features_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_features/lib/profiles/v2017_03_09/features_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_graph/lib/profiles/common/configurable.rb b/management/azure_mgmt_graph/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_graph/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_graph/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_graph/lib/profiles/latest/graph_latest_profile_client.rb b/management/azure_mgmt_graph/lib/profiles/latest/graph_latest_profile_client.rb index 56cfb398bb..029c06419e 100644 --- a/management/azure_mgmt_graph/lib/profiles/latest/graph_latest_profile_client.rb +++ b/management/azure_mgmt_graph/lib/profiles/latest/graph_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb b/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_iot_hub/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_iot_hub/lib/profiles/latest/iothub_latest_profile_client.rb b/management/azure_mgmt_iot_hub/lib/profiles/latest/iothub_latest_profile_client.rb index dabfa663d8..2d81df4d94 100644 --- a/management/azure_mgmt_iot_hub/lib/profiles/latest/iothub_latest_profile_client.rb +++ b/management/azure_mgmt_iot_hub/lib/profiles/latest/iothub_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb b/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_key_vault/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_key_vault/lib/profiles/latest/keyvault_latest_profile_client.rb b/management/azure_mgmt_key_vault/lib/profiles/latest/keyvault_latest_profile_client.rb index 56e41b0fa1..ceae4d7c8b 100644 --- a/management/azure_mgmt_key_vault/lib/profiles/latest/keyvault_latest_profile_client.rb +++ b/management/azure_mgmt_key_vault/lib/profiles/latest/keyvault_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_links/lib/profiles/common/configurable.rb b/management/azure_mgmt_links/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_links/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_links/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_links/lib/profiles/latest/links_latest_profile_client.rb b/management/azure_mgmt_links/lib/profiles/latest/links_latest_profile_client.rb index d13db264fa..b458b355c8 100644 --- a/management/azure_mgmt_links/lib/profiles/latest/links_latest_profile_client.rb +++ b/management/azure_mgmt_links/lib/profiles/latest/links_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_links/lib/profiles/v2017_03_09/links_v2017_03_09_profile_client.rb b/management/azure_mgmt_links/lib/profiles/v2017_03_09/links_v2017_03_09_profile_client.rb index f09c63ddd5..d228d47480 100644 --- a/management/azure_mgmt_links/lib/profiles/v2017_03_09/links_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_links/lib/profiles/v2017_03_09/links_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_locks/lib/profiles/common/configurable.rb b/management/azure_mgmt_locks/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_locks/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_locks/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_locks/lib/profiles/latest/locks_latest_profile_client.rb b/management/azure_mgmt_locks/lib/profiles/latest/locks_latest_profile_client.rb index 684a2e1212..a243054c98 100644 --- a/management/azure_mgmt_locks/lib/profiles/latest/locks_latest_profile_client.rb +++ b/management/azure_mgmt_locks/lib/profiles/latest/locks_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_locks/lib/profiles/v2017_03_09/locks_v2017_03_09_profile_client.rb b/management/azure_mgmt_locks/lib/profiles/v2017_03_09/locks_v2017_03_09_profile_client.rb index 34248cf0cb..5ae21acbe2 100644 --- a/management/azure_mgmt_locks/lib/profiles/v2017_03_09/locks_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_locks/lib/profiles/v2017_03_09/locks_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_logic/lib/profiles/common/configurable.rb b/management/azure_mgmt_logic/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_logic/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_logic/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_logic/lib/profiles/latest/logic_latest_profile_client.rb b/management/azure_mgmt_logic/lib/profiles/latest/logic_latest_profile_client.rb index 6568818599..a334e06e96 100644 --- a/management/azure_mgmt_logic/lib/profiles/latest/logic_latest_profile_client.rb +++ b/management/azure_mgmt_logic/lib/profiles/latest/logic_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb b/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_machine_learning/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_machine_learning/lib/profiles/latest/machinelearning_latest_profile_client.rb b/management/azure_mgmt_machine_learning/lib/profiles/latest/machinelearning_latest_profile_client.rb index 0310b3a741..2cfe004adc 100644 --- a/management/azure_mgmt_machine_learning/lib/profiles/latest/machinelearning_latest_profile_client.rb +++ b/management/azure_mgmt_machine_learning/lib/profiles/latest/machinelearning_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb b/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_managed_applications/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_managed_applications/lib/profiles/latest/managedapplications_latest_profile_client.rb b/management/azure_mgmt_managed_applications/lib/profiles/latest/managedapplications_latest_profile_client.rb index 92d04fdb3d..e1f378d29c 100644 --- a/management/azure_mgmt_managed_applications/lib/profiles/latest/managedapplications_latest_profile_client.rb +++ b/management/azure_mgmt_managed_applications/lib/profiles/latest/managedapplications_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb b/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_marketplace_ordering/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/marketplaceordering_latest_profile_client.rb b/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/marketplaceordering_latest_profile_client.rb index 9c2cb932c7..315f51cd2b 100644 --- a/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/marketplaceordering_latest_profile_client.rb +++ b/management/azure_mgmt_marketplace_ordering/lib/profiles/latest/marketplaceordering_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_media_services/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_media_services/lib/profiles/latest/mediaservices_latest_profile_client.rb b/management/azure_mgmt_media_services/lib/profiles/latest/mediaservices_latest_profile_client.rb index db43cd6398..ad3e465d93 100644 --- a/management/azure_mgmt_media_services/lib/profiles/latest/mediaservices_latest_profile_client.rb +++ b/management/azure_mgmt_media_services/lib/profiles/latest/mediaservices_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb b/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_mobile_engagement/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_mobile_engagement/lib/profiles/latest/mobileengagement_latest_profile_client.rb b/management/azure_mgmt_mobile_engagement/lib/profiles/latest/mobileengagement_latest_profile_client.rb index 62430fc176..03e3b9cc3b 100644 --- a/management/azure_mgmt_mobile_engagement/lib/profiles/latest/mobileengagement_latest_profile_client.rb +++ b/management/azure_mgmt_mobile_engagement/lib/profiles/latest/mobileengagement_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb b/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_monitor/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_monitor/lib/profiles/latest/monitor_latest_profile_client.rb b/management/azure_mgmt_monitor/lib/profiles/latest/monitor_latest_profile_client.rb index 2250141e67..152b046f78 100644 --- a/management/azure_mgmt_monitor/lib/profiles/latest/monitor_latest_profile_client.rb +++ b/management/azure_mgmt_monitor/lib/profiles/latest/monitor_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_network/lib/profiles/common/configurable.rb b/management/azure_mgmt_network/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_network/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_network/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_network/lib/profiles/latest/network_latest_profile_client.rb b/management/azure_mgmt_network/lib/profiles/latest/network_latest_profile_client.rb index 347234a3d0..98b5794c8c 100644 --- a/management/azure_mgmt_network/lib/profiles/latest/network_latest_profile_client.rb +++ b/management/azure_mgmt_network/lib/profiles/latest/network_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_network/lib/profiles/v2017_03_09/network_v2017_03_09_profile_client.rb b/management/azure_mgmt_network/lib/profiles/v2017_03_09/network_v2017_03_09_profile_client.rb index 20901663b5..c988715303 100644 --- a/management/azure_mgmt_network/lib/profiles/v2017_03_09/network_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_network/lib/profiles/v2017_03_09/network_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb b/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_notification_hubs/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_notification_hubs/lib/profiles/latest/notificationhubs_latest_profile_client.rb b/management/azure_mgmt_notification_hubs/lib/profiles/latest/notificationhubs_latest_profile_client.rb index 4127145a50..e8e54dd9bd 100644 --- a/management/azure_mgmt_notification_hubs/lib/profiles/latest/notificationhubs_latest_profile_client.rb +++ b/management/azure_mgmt_notification_hubs/lib/profiles/latest/notificationhubs_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb b/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_operational_insights/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_operational_insights/lib/profiles/latest/operationalinsights_latest_profile_client.rb b/management/azure_mgmt_operational_insights/lib/profiles/latest/operationalinsights_latest_profile_client.rb index 24103aea71..c66d0ec71a 100644 --- a/management/azure_mgmt_operational_insights/lib/profiles/latest/operationalinsights_latest_profile_client.rb +++ b/management/azure_mgmt_operational_insights/lib/profiles/latest/operationalinsights_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_policy/lib/profiles/common/configurable.rb b/management/azure_mgmt_policy/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_policy/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_policy/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_policy/lib/profiles/latest/policy_latest_profile_client.rb b/management/azure_mgmt_policy/lib/profiles/latest/policy_latest_profile_client.rb index bee4b91224..91f29da47d 100644 --- a/management/azure_mgmt_policy/lib/profiles/latest/policy_latest_profile_client.rb +++ b/management/azure_mgmt_policy/lib/profiles/latest/policy_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_policy/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb b/management/azure_mgmt_policy/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb index 064ec6627c..4b07059b50 100644 --- a/management/azure_mgmt_policy/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_policy/lib/profiles/v2017_03_09/policy_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb b/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_powerbi_embedded/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/powerbiembedded_latest_profile_client.rb b/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/powerbiembedded_latest_profile_client.rb index c2b0fbc285..f0a1da7fe9 100644 --- a/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/powerbiembedded_latest_profile_client.rb +++ b/management/azure_mgmt_powerbi_embedded/lib/profiles/latest/powerbiembedded_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_recovery_services/lib/profiles/latest/recoveryservices_latest_profile_client.rb b/management/azure_mgmt_recovery_services/lib/profiles/latest/recoveryservices_latest_profile_client.rb index 98de47b9d7..0f3301b697 100644 --- a/management/azure_mgmt_recovery_services/lib/profiles/latest/recoveryservices_latest_profile_client.rb +++ b/management/azure_mgmt_recovery_services/lib/profiles/latest/recoveryservices_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services_backup/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/recoveryservicesbackup_latest_profile_client.rb b/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/recoveryservicesbackup_latest_profile_client.rb index 1459aff9e9..967a70b73f 100644 --- a/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/recoveryservicesbackup_latest_profile_client.rb +++ b/management/azure_mgmt_recovery_services_backup/lib/profiles/latest/recoveryservicesbackup_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/recoveryservicessiterecovery_latest_profile_client.rb b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/recoveryservicessiterecovery_latest_profile_client.rb index 780c49f788..6613020a93 100644 --- a/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/recoveryservicessiterecovery_latest_profile_client.rb +++ b/management/azure_mgmt_recovery_services_site_recovery/lib/profiles/latest/recoveryservicessiterecovery_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_redis/lib/profiles/common/configurable.rb b/management/azure_mgmt_redis/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_redis/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_redis/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_redis/lib/profiles/latest/redis_latest_profile_client.rb b/management/azure_mgmt_redis/lib/profiles/latest/redis_latest_profile_client.rb index 119732a1a2..d3d8eaecf9 100644 --- a/management/azure_mgmt_redis/lib/profiles/latest/redis_latest_profile_client.rb +++ b/management/azure_mgmt_redis/lib/profiles/latest/redis_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_relay/lib/profiles/common/configurable.rb b/management/azure_mgmt_relay/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_relay/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_relay/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_relay/lib/profiles/latest/relay_latest_profile_client.rb b/management/azure_mgmt_relay/lib/profiles/latest/relay_latest_profile_client.rb index edd2526bea..751b905219 100644 --- a/management/azure_mgmt_relay/lib/profiles/latest/relay_latest_profile_client.rb +++ b/management/azure_mgmt_relay/lib/profiles/latest/relay_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_resources/lib/profiles/common/configurable.rb b/management/azure_mgmt_resources/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_resources/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_resources/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_resources/lib/profiles/latest/resources_latest_profile_client.rb b/management/azure_mgmt_resources/lib/profiles/latest/resources_latest_profile_client.rb index eb6feeba5d..4a0103f9d3 100644 --- a/management/azure_mgmt_resources/lib/profiles/latest/resources_latest_profile_client.rb +++ b/management/azure_mgmt_resources/lib/profiles/latest/resources_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_resources/lib/profiles/v2017_03_09/resources_v2017_03_09_profile_client.rb b/management/azure_mgmt_resources/lib/profiles/v2017_03_09/resources_v2017_03_09_profile_client.rb index 6254f68431..23a65c9faa 100644 --- a/management/azure_mgmt_resources/lib/profiles/v2017_03_09/resources_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_resources/lib/profiles/v2017_03_09/resources_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb b/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_resources_management/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_resources_management/lib/profiles/latest/resourcesmanagement_latest_profile_client.rb b/management/azure_mgmt_resources_management/lib/profiles/latest/resourcesmanagement_latest_profile_client.rb index 2fac9d1e74..b19806a5e0 100644 --- a/management/azure_mgmt_resources_management/lib/profiles/latest/resourcesmanagement_latest_profile_client.rb +++ b/management/azure_mgmt_resources_management/lib/profiles/latest/resourcesmanagement_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb b/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_scheduler/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_scheduler/lib/profiles/latest/scheduler_latest_profile_client.rb b/management/azure_mgmt_scheduler/lib/profiles/latest/scheduler_latest_profile_client.rb index 21b57a5f13..ac755048f2 100644 --- a/management/azure_mgmt_scheduler/lib/profiles/latest/scheduler_latest_profile_client.rb +++ b/management/azure_mgmt_scheduler/lib/profiles/latest/scheduler_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_search/lib/profiles/common/configurable.rb b/management/azure_mgmt_search/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_search/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_search/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_search/lib/profiles/latest/search_latest_profile_client.rb b/management/azure_mgmt_search/lib/profiles/latest/search_latest_profile_client.rb index 412dc8970a..66d91ee06c 100644 --- a/management/azure_mgmt_search/lib/profiles/latest/search_latest_profile_client.rb +++ b/management/azure_mgmt_search/lib/profiles/latest/search_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb b/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_server_management/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_server_management/lib/profiles/latest/servermanagement_latest_profile_client.rb b/management/azure_mgmt_server_management/lib/profiles/latest/servermanagement_latest_profile_client.rb index 78cb1a8898..c73a7143d8 100644 --- a/management/azure_mgmt_server_management/lib/profiles/latest/servermanagement_latest_profile_client.rb +++ b/management/azure_mgmt_server_management/lib/profiles/latest/servermanagement_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb b/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_service_bus/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_service_bus/lib/profiles/latest/servicebus_latest_profile_client.rb b/management/azure_mgmt_service_bus/lib/profiles/latest/servicebus_latest_profile_client.rb index 7eeb60fee1..5ca5f6e58f 100644 --- a/management/azure_mgmt_service_bus/lib/profiles/latest/servicebus_latest_profile_client.rb +++ b/management/azure_mgmt_service_bus/lib/profiles/latest/servicebus_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb b/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_service_fabric/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_service_fabric/lib/profiles/latest/servicefabric_latest_profile_client.rb b/management/azure_mgmt_service_fabric/lib/profiles/latest/servicefabric_latest_profile_client.rb index 71c26c3ff3..07a62b69f5 100644 --- a/management/azure_mgmt_service_fabric/lib/profiles/latest/servicefabric_latest_profile_client.rb +++ b/management/azure_mgmt_service_fabric/lib/profiles/latest/servicefabric_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_sql/lib/profiles/common/configurable.rb b/management/azure_mgmt_sql/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_sql/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_sql/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_sql/lib/profiles/latest/sql_latest_profile_client.rb b/management/azure_mgmt_sql/lib/profiles/latest/sql_latest_profile_client.rb index 5014aea6d1..5cec06e8a4 100644 --- a/management/azure_mgmt_sql/lib/profiles/latest/sql_latest_profile_client.rb +++ b/management/azure_mgmt_sql/lib/profiles/latest/sql_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb b/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_stor_simple8000_series/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/storsimple8000series_latest_profile_client.rb b/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/storsimple8000series_latest_profile_client.rb index 2293923072..09a9dbc3cc 100644 --- a/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/storsimple8000series_latest_profile_client.rb +++ b/management/azure_mgmt_stor_simple8000_series/lib/profiles/latest/storsimple8000series_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_storage/lib/profiles/common/configurable.rb b/management/azure_mgmt_storage/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_storage/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_storage/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_storage/lib/profiles/latest/storage_latest_profile_client.rb b/management/azure_mgmt_storage/lib/profiles/latest/storage_latest_profile_client.rb index ccf5712836..76b677fe27 100644 --- a/management/azure_mgmt_storage/lib/profiles/latest/storage_latest_profile_client.rb +++ b/management/azure_mgmt_storage/lib/profiles/latest/storage_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_storage/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb b/management/azure_mgmt_storage/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb index d0c25aafe1..98babe6bed 100644 --- a/management/azure_mgmt_storage/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_storage/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb b/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_stream_analytics/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_stream_analytics/lib/profiles/latest/streamanalytics_latest_profile_client.rb b/management/azure_mgmt_stream_analytics/lib/profiles/latest/streamanalytics_latest_profile_client.rb index e698e4aab3..f1a8014328 100644 --- a/management/azure_mgmt_stream_analytics/lib/profiles/latest/streamanalytics_latest_profile_client.rb +++ b/management/azure_mgmt_stream_analytics/lib/profiles/latest/streamanalytics_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb b/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_subscriptions/lib/profiles/latest/subscriptions_latest_profile_client.rb b/management/azure_mgmt_subscriptions/lib/profiles/latest/subscriptions_latest_profile_client.rb index af94b13af3..af585e2608 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/latest/subscriptions_latest_profile_client.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/latest/subscriptions_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/subscriptions_v2017_03_09_profile_client.rb b/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/subscriptions_v2017_03_09_profile_client.rb index 308f52f052..a02e7a4f91 100644 --- a/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/subscriptions_v2017_03_09_profile_client.rb +++ b/management/azure_mgmt_subscriptions/lib/profiles/v2017_03_09/subscriptions_v2017_03_09_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb b/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_traffic_manager/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_traffic_manager/lib/profiles/latest/trafficmanager_latest_profile_client.rb b/management/azure_mgmt_traffic_manager/lib/profiles/latest/trafficmanager_latest_profile_client.rb index 0b35a8c23a..dad010c71b 100644 --- a/management/azure_mgmt_traffic_manager/lib/profiles/latest/trafficmanager_latest_profile_client.rb +++ b/management/azure_mgmt_traffic_manager/lib/profiles/latest/trafficmanager_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end diff --git a/management/azure_mgmt_web/lib/profiles/common/configurable.rb b/management/azure_mgmt_web/lib/profiles/common/configurable.rb index 792897cb8a..0e4922239a 100644 --- a/management/azure_mgmt_web/lib/profiles/common/configurable.rb +++ b/management/azure_mgmt_web/lib/profiles/common/configurable.rb @@ -50,7 +50,16 @@ def reset!(options = {}) instance_variable_set(:"@#{key}", options.fetch(key, default_value)) end - default_value = get_credentials(self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings) + fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil? + fail ArgumentError, 'client_id is nil' if self.client_id.nil? + fail ArgumentError, 'client_secret is nil' if self.client_secret.nil? + fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil? + fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil? + + default_value = MsRest::TokenCredentials.new( + MsRestAzure::ApplicationTokenProvider.new( + self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) + instance_variable_set(:"@credentials", options.fetch(:credentials, default_value)) self @@ -70,15 +79,8 @@ def setup_default_options Azure::Common::Configurable.keys.map do |key| opts[key] = Azure::Common::Default.options[key] end - opts[:credentials] = get_credentials(opts[:tenant_id], opts[:client_id], opts[:client_secret], opts[:active_directory_settings]) - opts - end - def get_credentials(tenant_id, client_id, client_secret, active_directory_settings) - MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - tenant_id, client_id, client_secret, active_directory_settings)) + opts end - end end diff --git a/management/azure_mgmt_web/lib/profiles/latest/web_latest_profile_client.rb b/management/azure_mgmt_web/lib/profiles/latest/web_latest_profile_client.rb index dee908fbc0..a5fc57cdbf 100644 --- a/management/azure_mgmt_web/lib/profiles/latest/web_latest_profile_client.rb +++ b/management/azure_mgmt_web/lib/profiles/latest/web_latest_profile_client.rb @@ -19,15 +19,5 @@ def initialize(options = {}) super(options) end - def credentials - if @credentials.nil? - self.active_directory_settings ||= Azure::Common::Default.active_directory_settings - - @credentials = MsRest::TokenCredentials.new( - MsRestAzure::ApplicationTokenProvider.new( - self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings)) - end - @credentials - end end end From 2f87e290d3a9625d339bcfc3d66b0f4619ecdcea Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 26 Oct 2017 13:06:04 -0700 Subject: [PATCH 7/9] Minor addition to readme file --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6760563d62..762d2a89d5 100644 --- a/README.md +++ b/README.md @@ -267,6 +267,8 @@ gem install 'azure_mgmt_compute' The following lines should be used to instantiate a profile client: ```ruby +# To use this scenario, you must specify the tenant id, client id, subscription id +# and client secret using the environment variables. # Provide credentials provider = MsRestAzure::ApplicationTokenProvider.new( ENV['AZURE_TENANT_ID'], From c6c093ba41aa95727606302542b27afa4054d494 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 26 Oct 2017 14:49:52 -0700 Subject: [PATCH 8/9] PR Comments --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 762d2a89d5..e1f5aca224 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,21 @@ You can set the (above) values using the following environment variables: * AZURE_SUBSCRIPTION_ID * AZURE_CLIENT_SECRET +To set the environment variables, in Windows, you could use the command such as: + +``` +set AZURE_TENANT_ID= +``` + +In Unix based systems, you could use the command such as: + +``` +export AZURE_TENANT_ID= +``` + ### Option 2 - Options Hash +The initialization of profile clients take an options hash as a parameter. This options hash consists of tenant_id, client_id, client_secret, subscription_id, active_directory_settings and credentials. Among these, the active_directory_settings and credentials are optional. + You can set the (above) values using the options hash: ```ruby @@ -94,6 +108,24 @@ options = { } ``` +If you would like to pass in the credentials object, you could use the the following code: + +```ruby +provider = MsRestAzure::ApplicationTokenProvider.new( + ENV['AZURE_TENANT_ID'], + ENV['AZURE_CLIENT_ID'], + ENV['AZURE_CLIENT_SECRET']) +credentials = MsRest::TokenCredentials.new(provider) + +options = { + tenant_id: 'YOUR TENANT ID', + client_id: 'YOUR CLIENT ID', + client_secret: 'YOUR CLIENT SECRET', + subscription_id: 'YOUR SUBSCRIPTION ID', + credentials: credentials +} +``` + ### Option 3 - Combination of Environment Variables & Options Hash You can set the (above) values using a combination of environment variables and options hash. The values mentioned in the options hash will take precedence over the environment variables. From 9a7b70e41f09604e77ef4d2ff3f85d87bbca88ea Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 26 Oct 2017 15:19:10 -0700 Subject: [PATCH 9/9] Move position of the section --- README.md | 74 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index e1f5aca224..e65cde0fd9 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,39 @@ Additional info on Azure deployment models [https://azure.microsoft.com/en-us/do Note: x64 Ruby for Windows is known to have some compatibility issues. # Getting Started with Azure Resource Manager Usage (Preview) +## Install the rubygem packages + +You can install the azure rubygem packages directly. + +```bash +gem install azure_mgmt_compute +gem install azure_mgmt_storage +gem install azure_mgmt_resources +gem install azure_mgmt_network +``` + +Or use them in your Gemfile. + +```Ruby +gem 'azure_mgmt_storage' +gem 'azure_mgmt_compute' +gem 'azure_mgmt_resources' +gem 'azure_mgmt_network' +``` + +Be aware the Azure Resource Manager Ruby SDK is in preview and will likely have breaking interface changes in upcoming +releases. An increased number in Minor version may indicate breaking changes. + +### Authentication + +The first step to using the SDK is authentication and permissions. For people unfamilar with Azure this may be one of +the more difficult concepts. For a reference on setting up a service principal from the command line see +[Authenticating a service principal with Azure Resource Manager](http://aka.ms/cli-service-principal) or +[Unattended Authentication](http://aka.ms/auth-unattended). For a more robust explanation of authentication in Azure, +see [Developer’s guide to auth with Azure Resource Manager API](http://aka.ms/arm-auth-dev-guide). + +After creating the service principal, you should have three pieces of information, a client id (GUID), client secret +(string) and tenant id (GUID) or domain name (string). ## Prerequisite @@ -112,9 +145,9 @@ If you would like to pass in the credentials object, you could use the the follo ```ruby provider = MsRestAzure::ApplicationTokenProvider.new( - ENV['AZURE_TENANT_ID'], - ENV['AZURE_CLIENT_ID'], - ENV['AZURE_CLIENT_SECRET']) + 'YOUR TENANT ID', + 'YOUR CLIENT ID', + 'YOUR CLIENT SECRET') credentials = MsRest::TokenCredentials.new(provider) options = { @@ -129,41 +162,6 @@ options = { ### Option 3 - Combination of Environment Variables & Options Hash You can set the (above) values using a combination of environment variables and options hash. The values mentioned in the options hash will take precedence over the environment variables. - -## Install the rubygem packages - -You can install the azure rubygem packages directly. - -```bash -gem install azure_mgmt_compute -gem install azure_mgmt_storage -gem install azure_mgmt_resources -gem install azure_mgmt_network -``` - -Or use them in your Gemfile. - -```Ruby -gem 'azure_mgmt_storage' -gem 'azure_mgmt_compute' -gem 'azure_mgmt_resources' -gem 'azure_mgmt_network' -``` - -Be aware the Azure Resource Manager Ruby SDK is in preview and will likely have breaking interface changes in upcoming -releases. An increased number in Minor version may indicate breaking changes. - -### Authentication - -The first step to using the SDK is authentication and permissions. For people unfamilar with Azure this may be one of -the more difficult concepts. For a reference on setting up a service principal from the command line see -[Authenticating a service principal with Azure Resource Manager](http://aka.ms/cli-service-principal) or -[Unattended Authentication](http://aka.ms/auth-unattended). For a more robust explanation of authentication in Azure, -see [Developer’s guide to auth with Azure Resource Manager API](http://aka.ms/arm-auth-dev-guide). - -After creating the service principal, you should have three pieces of information, a client id (GUID), client secret -(string) and tenant id (GUID) or domain name (string). - # Azure Multiple API versions & Profiles With 0.15.0 of Azure SDK, multiple API versions and profiles are introduced. With these changes, each individual gem