Skip to content

Commit

Permalink
Add SQL Virtual Network Rules and DNS Aliases (#244)
Browse files Browse the repository at this point in the history
* Add Fluent support for SQL Virtual Network Rules
* Add Fluent support for SQL server DNS aliases
  • Loading branch information
milismsft authored Mar 12, 2018
1 parent 96ea463 commit 27915c3
Show file tree
Hide file tree
Showing 30 changed files with 5,718 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public interface SqlChildrenOperations<T> {
*/
T getBySqlServer(SqlServer sqlServer, String name);

/**
* Asynchronously gets the information about a child resource from Azure SQL server, identifying it by its name and its resource group.
*
* @param sqlServer the SQL server parent resource
* @param name the name of the child resource
* @return a representation of the deferred computation of this call returning the found resource
*/
@Beta(Beta.SinceVersion.V1_8_0)
Observable<T> getBySqlServerAsync(SqlServer sqlServer, String name);

/**
* Gets the information about a child resource from Azure SQL server using the resource ID.
*
Expand Down Expand Up @@ -125,9 +135,17 @@ public interface SqlChildrenOperations<T> {
* @param sqlServer the parent Azure SQL server.
* @return the list of resources
*/
@Deprecated
List<T> listBySqlServer(SqlServer sqlServer);

/**
* Asynchronously lists Azure SQL child resources of the specified Azure SQL server in the specified resource group.
*
* @param sqlServer the parent Azure SQL server.
* @return a representation of the deferred computation of this call
*/
@Beta(Beta.SinceVersion.V1_8_0)
Observable<T> listBySqlServerAsync(SqlServer sqlServer);

/**
* Base interface for Azure SQL Server child resource actions.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ interface WithIPAddressRange {
* The final stage of the SQL Firewall Rule definition.
*/
interface WithCreate extends Creatable<SqlFirewallRule> {
// interface WithCreate extends SqlChildrenCreatableDefinition<SqlFirewallRule> {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ public interface SqlServer extends
@Beta(Beta.SinceVersion.V1_7_0)
SqlFirewallRuleOperations.SqlFirewallRuleActionsDefinition firewallRules();

/**
* @return returns entry point to manage SQL Virtual Network Rule for this server.
*/
@Beta(Beta.SinceVersion.V1_8_0)
SqlVirtualNetworkRuleOperations.SqlVirtualNetworkRuleActionsDefinition virtualNetworkRules();

/**
* @return returns entry point to manage the SQL Elastic Pools for this server.
*/
Expand All @@ -218,6 +224,12 @@ public interface SqlServer extends
@Beta(Beta.SinceVersion.V1_7_0)
SqlDatabaseOperations.SqlDatabaseActionsDefinition databases();

/**
* @return returns entry point to manage SQL Server DNS aliases for this server.
*/
@Beta(Beta.SinceVersion.V1_8_0)
SqlServerDnsAliasOperations.SqlServerDnsAliasActionsDefinition dnsAliases();


/**************************************************************
* Fluent interfaces to provision a SqlServer
Expand Down Expand Up @@ -422,6 +434,21 @@ interface WithFirewallRule {
WithCreate withNewFirewallRule(String startIPAddress, String endIPAddress, String firewallRuleName);
}

/**
* The stage of the SQL Server definition allowing to specify the SQL Virtual Network Rules.
*/
@Beta(Beta.SinceVersion.V1_8_0)
interface WithVirtualNetworkRule {
/**
* Begins the definition of a new SQL Virtual Network Rule to be added to this server.
*
* @param virtualNetworkRuleName the name of the new SQL Virtual Network Rule
* @return the first stage of the new SQL Virtual Network Rule definition
*/
@Beta(Beta.SinceVersion.V1_8_0)
SqlVirtualNetworkRule.DefinitionStages.Blank<WithCreate> defineVirtualNetworkRule(String virtualNetworkRuleName);
}

/**
* A SQL Server definition with sufficient inputs to create a new
* SQL Server in the cloud, but exposing additional optional inputs to
Expand All @@ -435,6 +462,7 @@ interface WithCreate extends
WithElasticPool,
WithDatabase,
WithFirewallRule,
WithVirtualNetworkRule,
DefinitionWithTags<WithCreate> {
}
}
Expand Down Expand Up @@ -541,8 +569,6 @@ interface WithDatabase {
Update withoutDatabase(String databaseName);
}



/**
* The stage of the SQL Server update definition allowing to specify the SQL Firewall rules.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.management.sql;

import com.microsoft.azure.management.apigeneration.Beta;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.apigeneration.Method;
import com.microsoft.azure.management.resources.fluentcore.arm.models.HasId;
import com.microsoft.azure.management.resources.fluentcore.arm.models.HasName;
import com.microsoft.azure.management.resources.fluentcore.arm.models.HasResourceGroup;
import com.microsoft.azure.management.resources.fluentcore.model.HasInner;
import com.microsoft.azure.management.resources.fluentcore.model.Indexable;
import com.microsoft.azure.management.resources.fluentcore.model.Refreshable;
import com.microsoft.azure.management.sql.implementation.ServerDnsAliasInner;
import rx.Completable;

/**
* An immutable client-side representation of an Azure SQL Server DNS alias.
*/
@Fluent
@Beta(Beta.SinceVersion.V1_8_0)
public interface SqlServerDnsAlias
extends
HasId,
HasInner<ServerDnsAliasInner>,
HasName,
HasResourceGroup,
Indexable,
Refreshable<SqlServerDnsAlias> {
/**
* @return name of the SQL Server to which this DNS alias belongs
*/
String sqlServerName();

/**
* @return the fully qualified DNS record for alias
*/
String azureDnsRecord();

/**
* @return the parent SQL server ID
*/
String parentId();

/**
* Deletes the DNS alias.
*/
@Method
void delete();

/**
* Deletes the DNS alias asynchronously.
*
* @return a representation of the deferred computation of this call
*/
@Method
Completable deleteAsync();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.management.sql;

import com.microsoft.azure.management.apigeneration.Beta;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.model.Creatable;
import rx.Completable;

/**
* A representation of the Azure SQL Server DNS alias operations.
*/
@Fluent
@Beta(Beta.SinceVersion.V1_8_0)
public interface SqlServerDnsAliasOperations extends
SupportsCreating<SqlServerDnsAliasOperations.DefinitionStages.WithSqlServer>,
SqlChildrenOperations<SqlServerDnsAlias> {

/**
* Acquires server DNS alias from another server.
*
* @param resourceGroupName the name of the resource group that contains the resource
* @param serverName the name of the server that the alias is pointing to
* @param dnsAliasName the name of the Server DNS alias
* @param sqlServerId the id of the other SQL server that the DNS alias was pointing to
*/
void acquire(String resourceGroupName, String serverName, String dnsAliasName, String sqlServerId);

/**
* Acquires server DNS alias from another server asynchronously.
*
* @param resourceGroupName the name of the resource group that contains the resource
* @param serverName the name of the server that the alias is pointing to
* @param dnsAliasName the name of the Server DNS alias
* @param sqlServerId the id of the other SQL server that the DNS alias was pointing to
* @return a representation of the deferred computation of this call
*/
Completable acquireAsync(String resourceGroupName, String serverName, String dnsAliasName, String sqlServerId);

/**
* Acquires server DNS alias from another server.
*
* @param dnsAliasName the name of the Server DNS alias
* @param oldSqlServerId the id of the other SQL server that the DNS alias was pointing to
* @param newSqlServerId the id of the server that the alias is pointing to
*/
void acquire(String dnsAliasName, String oldSqlServerId, String newSqlServerId);

/**
* Acquires server DNS alias from another server asynchronously.
*
* @param dnsAliasName the name of the Server DNS alias
* @param oldSqlServerId the id of the other SQL server that the DNS alias was pointing to
* @param newSqlServerId the id of the server that the alias is pointing to
* @return a representation of the deferred computation of this call
*/
Completable acquireAsync(String dnsAliasName, String oldSqlServerId, String newSqlServerId);

/**
* Container interface for all the definitions that need to be implemented.
*/
@Beta(Beta.SinceVersion.V1_8_0)
interface SqlServerDnsAliasOperationsDefinition extends
SqlServerDnsAliasOperations.DefinitionStages.WithSqlServer,
SqlServerDnsAliasOperations.DefinitionStages.WithCreate {
}

/**
* Grouping of all the SQL Server DNS alias definition stages.
*/
@Beta(Beta.SinceVersion.V1_8_0)
interface DefinitionStages {
/**
* The first stage of the SQL Server DNS alias definition.
*/
@Beta(Beta.SinceVersion.V1_8_0)
interface WithSqlServer {
/**
* Sets the parent SQL server name and resource group it belongs to.
*
* @param resourceGroupName the name of the resource group the parent SQL server
* @param sqlServerName the parent SQL server name
* @return The next stage of the definition.
*/
SqlServerDnsAliasOperations.DefinitionStages.WithCreate withExistingSqlServer(String resourceGroupName, String sqlServerName);

/**
* Sets the parent SQL server for the new Server DNS alias.
*
* @param sqlServerId the parent SQL server ID
* @return The next stage of the definition.
*/
SqlServerDnsAliasOperations.DefinitionStages.WithCreate withExistingSqlServerId(String sqlServerId);

/**
* Sets the parent SQL server for the new Server DNS alias.
*
* @param sqlServer the parent SQL server
* @return The next stage of the definition.
*/
SqlServerDnsAliasOperations.DefinitionStages.WithCreate withExistingSqlServer(SqlServer sqlServer);
}

/**
* The final stage of the SQL Server DNS alias definition.
*/
interface WithCreate extends Creatable<SqlServerDnsAlias> {
}
}

/**
* Grouping of the Azure SQL Server DNS alias common actions.
*/
@Beta(Beta.SinceVersion.V1_8_0)
interface SqlServerDnsAliasActionsDefinition extends SqlChildrenActionsDefinition<SqlServerDnsAlias> {
/**
* Begins the definition of a new SQL ServerDNS alias to be added to this server.
*
* @param serverDnsAliasName the name of the new DNS alias to be created for the selected SQL server
* @return the first stage of the new SQL Virtual Network Rule definition
*/
SqlServerDnsAliasOperations.DefinitionStages.WithCreate define(String serverDnsAliasName);

/**
* Acquires server DNS alias from another server.
*
* @param dnsAliasName the name of the Server DNS alias
* @param sqlServerId the id of the other SQL server that the DNS alias was pointing to
*/
void acquire(String dnsAliasName, String sqlServerId);

/**
* Acquires server DNS alias from another server asynchronously.
*
* @param dnsAliasName the name of the Server DNS alias
* @param sqlServerId the id of the other SQL server that the DNS alias was pointing to
* @return a representation of the deferred computation of this call
*/
Completable acquireAsync(String dnsAliasName, String sqlServerId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ public interface SqlServers extends
@Beta(Beta.SinceVersion.V1_7_0)
SqlFirewallRuleOperations firewallRules();

/**
* @return the SQL Server VirtualNetwork Rules API entry point
*/
@Beta(Beta.SinceVersion.V1_8_0)
SqlVirtualNetworkRuleOperations virtualNetworkRules();

/**
* @return the SQL Server DNS aliases API entry point
*/
@Beta(Beta.SinceVersion.V1_8_0)
SqlServerDnsAliasOperations dnsAliases();

/**
* @return the SQL Server Elastic Pools API entry point
*/
Expand Down
Loading

0 comments on commit 27915c3

Please sign in to comment.