Class: Azure::SqlDatabaseManagement::SqlDatabaseManagementService
- Inherits:
-
BaseManagement::BaseManagementService
- Object
- BaseManagement::BaseManagementService
- Azure::SqlDatabaseManagement::SqlDatabaseManagementService
- Defined in:
- lib/azure/sql_database_management/sql_database_management_service.rb
Instance Method Summary collapse
-
#create_server(login, password, location) ⇒ Object
Public: Create a new database server in Microsoft Azure.
-
#delete_server(name) ⇒ Object
Public: Deletes the specified database server of given subscription id from Microsoft Azure.
-
#delete_sql_server_firewall_rule(server_name, rule_name) ⇒ Object
Public: Deletes a server-level firewall rule from a SQL Database server.
-
#initialize ⇒ SqlDatabaseManagementService
constructor
A new instance of SqlDatabaseManagementService.
-
#list_servers ⇒ Object
Public: Gets a list of database servers available under the current subscription.
-
#list_sql_server_firewall_rules(server_name) ⇒ Object
Public: Gets a list of server-level firewall rules set for SQL database server.
-
#reset_password(name, password) ⇒ Object
Public: Sets the administrative password of a SQL Database server for a subscription.
-
#set_sql_server_firewall_rule(server_name, rule_name, options = {}) ⇒ Object
Public: The Set Server Firewall Rule operation for the given subscription adds a new server-level firewall or updates an existing server-level firewall rule for a SQL Database server.
Methods inherited from BaseManagement::BaseManagementService
#create_affinity_group, #delete_affinity_group, #get_affinity_group, #list_affinity_groups, #list_locations, #list_role_sizes, #update_affinity_group, #validate_configuration
Constructor Details
#initialize ⇒ SqlDatabaseManagementService
Returns a new instance of SqlDatabaseManagementService.
21 22 23 |
# File 'lib/azure/sql_database_management/sql_database_management_service.rb', line 21 def initialize super() end |
Instance Method Details
#create_server(login, password, location) ⇒ Object
Public: Create a new database server in Microsoft Azure.
Attributes
-
login
- String. The administrator login name. -
password
- String. The administrator login password. -
:location
- String. The location where the database server will be created.
See msdn.microsoft.com/en-us/library/azure/gg715274.aspx
Returns Azure::SqlDatabaseManagement::SqlDatabase object
49 50 51 52 53 54 55 56 57 |
# File 'lib/azure/sql_database_management/sql_database_management_service.rb', line 49 def create_server(login, password, location) body = Serialization.database_to_xml(login, password, location) request_path = '/servers' request = BaseManagement::SqlManagementHttpRequest.new(:post, request_path, body) response = request.call sql_server = Serialization.server_name_from_xml(response, login, location) Azure::Loggerx.info "SQL database server #{sql_server.name} is created." if sql_server sql_server end |
#delete_server(name) ⇒ Object
Public: Deletes the specified database server of given subscription id from Microsoft Azure.
Attributes
-
name
- String. Database server name.
See msdn.microsoft.com/en-us/library/azure/gg715285.aspx
Returns: None
69 70 71 72 73 74 75 76 |
# File 'lib/azure/sql_database_management/sql_database_management_service.rb', line 69 def delete_server(name) if get_sql_server(name) request_path = "/servers/#{name}" request = BaseManagement::SqlManagementHttpRequest.new(:delete, request_path) request.call Azure::Loggerx.info "Deleted database server #{name}." end end |
#delete_sql_server_firewall_rule(server_name, rule_name) ⇒ Object
Public: Deletes a server-level firewall rule from a SQL Database server.
Attributes
-
name
- String. SQL database server name. -
rule_name
- String. SQL database server firewall rule name.
See msdn.microsoft.com/en-us/library/azure/gg715277.aspx
Returns: None
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/azure/sql_database_management/sql_database_management_service.rb', line 170 def delete_sql_server_firewall_rule(server_name, rule_name) if !list_sql_server_firewall_rules(server_name).collect{|x| x[:rule]}.include?(rule_name) error = "The specified firewall rule #{rule_name} does not exist." raise error elsif get_sql_server(server_name) request_path = "/servers/#{server_name}/firewallrules/#{rule_name}" request = BaseManagement::SqlManagementHttpRequest.new(:delete, request_path) request.call Azure::Loggerx.info "Deleted server-level firewall rule #{rule_name}." end end |
#list_servers ⇒ Object
Public: Gets a list of database servers available under the current subscription.
See msdn.microsoft.com/en-us/library/azure/gg715269.aspx
Returns an array of Azure::SqlDatabaseManagement::SqlDatabase objects
31 32 33 34 35 36 |
# File 'lib/azure/sql_database_management/sql_database_management_service.rb', line 31 def list_servers request_path = '/servers' request = BaseManagement::SqlManagementHttpRequest.new(:get, request_path, nil) response = request.call Serialization.databases_from_xml(response) end |
#list_sql_server_firewall_rules(server_name) ⇒ Object
Public: Gets a list of server-level firewall rules set for SQL database server.
Attributes
-
server_name
- String. Database server name.
See msdn.microsoft.com/en-us/library/azure/gg715278.aspx
Returns an array of firewall
151 152 153 154 155 156 157 158 |
# File 'lib/azure/sql_database_management/sql_database_management_service.rb', line 151 def list_sql_server_firewall_rules(server_name) if get_sql_server(server_name) request_path = "/servers/#{server_name}/firewallrules" request = BaseManagement::SqlManagementHttpRequest.new(:get, request_path) response = request.call Serialization.database_firewall_from_xml(response) end end |
#reset_password(name, password) ⇒ Object
Public: Sets the administrative password of a SQL Database server for a subscription.
Attributes
-
name
- String. Database server name. -
password
- String. Database server new password.
See msdn.microsoft.com/en-us/library/azure/gg715272.aspx
Returns: None
89 90 91 92 93 94 95 96 97 |
# File 'lib/azure/sql_database_management/sql_database_management_service.rb', line 89 def reset_password(name, password) if get_sql_server(name) body = Serialization.reset_password_to_xml(password) request_path = "/servers/#{name}?op=ResetPassword" request = BaseManagement::SqlManagementHttpRequest.new(:post, request_path, body) request.call Azure::Loggerx.info "Password for server #{name} changed successfully." end end |
#set_sql_server_firewall_rule(server_name, rule_name, options = {}) ⇒ Object
Public: The Set Server Firewall Rule operation for the given subscription adds a new server-level firewall or updates an existing server-level firewall rule for a SQL Database server.
Attributes
-
server_name
- String. Database server name. -
rule_name
- String. Database server new password.
==== Options
Accepted key/value pairs are:
-
:start_ip_address
- String. Start of the IP Range -
:end_ip_address
- String. End of the IP Range
See msdn.microsoft.com/en-us/library/azure/gg715280.aspx
Returns: None
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/azure/sql_database_management/sql_database_management_service.rb', line 117 def set_sql_server_firewall_rule(server_name, rule_name, = {}) unless server_name.class == String && rule_name.class == String raise "Missing parameter server_name or rule_name." end if get_sql_server(server_name) if [:start_ip_address] || [:end_ip_address] body = Serialization.firewall_rule_to_xml() request_path = "/servers/#{server_name}/firewallrules/#{rule_name}" method = :put else request_path = "/servers/#{server_name}/firewallrules/#{rule_name}?op=AutoDetectClientIP" method = :post end request = BaseManagement::SqlManagementHttpRequest.new(method, request_path, body) request.headers['x-ms-version'] = '1.0' request.uri = URI.parse(Azure.config.sql_database_management_endpoint + Azure.config.subscription_id + request_path) # Management certificate authentication Endpoint throws errors for this operation. Need to re-visit # this once the Azure API is working. request.call Azure::Loggerx.info "Added server-level firewall rule #{rule_name}." end end |