lib/fog/azurerm/sql.rb in fog-azure-rm-0.1.2 vs lib/fog/azurerm/sql.rb in fog-azure-rm-0.2.0
- old
+ new
@@ -4,26 +4,30 @@
class AzureRM < Fog::Service
requires :tenant_id
requires :client_id
requires :client_secret
requires :subscription_id
+ recognizes :environment
request_path 'fog/azurerm/requests/sql'
request :create_or_update_sql_server
request :delete_sql_server
request :get_sql_server
request :list_sql_servers
+ request :check_sql_server_exists
request :create_or_update_database
request :delete_database
request :get_database
request :list_databases
+ request :check_database_exists
request :create_or_update_firewall_rule
request :delete_firewall_rule
request :get_firewall_rule
request :list_firewall_rules
+ request :check_firewall_rule_exists
model_path 'fog/azurerm/models/sql'
model :sql_server
collection :sql_servers
@@ -34,19 +38,23 @@
collection :firewall_rules
# This class provides the actual implementation for service calls.
class Real
def initialize(options)
- @tenant_id = options[:tenant_id]
- @client_id = options[:client_id]
- @client_secret = options[:client_secret]
- @subscription_id = options[:subscription_id]
- @resources = Fog::Resources::AzureRM.new(
- tenant_id: options[:tenant_id],
- client_id: options[:client_id],
- client_secret: options[:client_secret],
- subscription_id: options[:subscription_id]
- )
+ begin
+ require 'azure_mgmt_sql'
+ rescue LoadError => e
+ retry if require('rubygems')
+ raise e.message
+ end
+
+ options[:environment] = 'AzureCloud' if options[:environment].nil?
+
+ credentials = Fog::Credentials::AzureRM.get_credentials(options[:tenant_id], options[:client_id], options[:client_secret], options[:environment])
+ @sql_mgmt_client = ::Azure::ARM::SQL::SqlManagementClient.new(credentials, resource_manager_endpoint_url(options[:environment]))
+ @sql_mgmt_client.subscription_id = options[:subscription_id]
+ telemetry = "fog-azure-rm/#{Fog::AzureRM::VERSION}"
+ @sql_mgmt_client.add_user_agent_information(telemetry)
end
end
# This class provides the mock implementation for unit tests.
class Mock
def initialize(_options = {})