Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String regionName() {

@Override
public Region region() {
return Region.fromName(this.regionName());
return Region.fromLabelOrName(this.regionName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,29 +192,21 @@ interface WithElasticPoolName {
* @param elasticPoolName for the SQL Database.
* @return The next stage of definition.
*/
WithCreate withExistingElasticPoolName(String elasticPoolName);
WithCreate withExistingElasticPool(String elasticPoolName);

/**
* Sets the existing elastic pool for the SQLDatabase.
* @param sqlElasticPool for the SQL Database.
* @return The next stage of definition.
*/
WithCreate withExistingElasticPoolName(SqlElasticPool sqlElasticPool);

/**
* Sets the new elastic pool for the SQLDatabase, this will create a new elastic pool while creating database.
* @param elasticPoolName name for new elastic pool to be created for the SQL Database.
* @param elasticPoolEdition edition for new elastic pool to be created for the SQL Database.
* @return The next stage of definition.
*/
WithCreate withNewElasticPool(String elasticPoolName, ElasticPoolEditions elasticPoolEdition);
WithCreate withExistingElasticPool(SqlElasticPool sqlElasticPool);

/**
* Sets the new elastic pool for the SQLDatabase, this will create a new elastic pool while creating database.
* @param sqlElasticPool creatable definition for new elastic pool to be created for the SQL Database.
* @return The next stage of definition.
*/
WithCreate withNewElasticPool(SqlElasticPool.DefinitionStages.WithCreate sqlElasticPool);
WithCreate withNewElasticPool(Creatable<SqlElasticPool> sqlElasticPool);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ interface Definition extends
DefinitionStages.Blank,
DefinitionStages.WithEdition,
DefinitionStages.WithCreate {

}

/**
Expand All @@ -101,55 +100,138 @@ interface WithEdition {
}

/**
* A resource definition allowing SQLServer to be attached with SQLDatabase.
* The SQL Elastic Pool definition to set the minimum DTU for database.
*/
interface WithSqlServer {
interface WithDatabaseDtuMin {
/**
* Creates a new SqlElasticPool resource under SQLServer.
* Sets the minimum DTU all SQL Azure Databases are guaranteed.
*
* @param groupName the name of the resource group for SQLServer.
* @param sqlServerName the name of the sQLServer.
* @return the creatable for the child resource
* @param databaseDtuMin minimum DTU for all SQL Azure databases
* @return The next stage of definition.
*/
Creatable<SqlElasticPool> withExistingSqlServer(String groupName, String sqlServerName);
SqlElasticPool.DefinitionStages.WithCreate withDatabaseDtuMin(int databaseDtuMin);
}

/**
* The SQL Elastic Pool definition to set the maximum DTU for one database.
*/
interface WithDatabaseDtuMax {
/**
* Sets the maximum DTU any one SQL Azure Database can consume.
*
* @param databaseDtuMax maximum DTU any one SQL Azure Database can consume
* @return The next stage of definition.
*/
SqlElasticPool.DefinitionStages.WithCreate withDatabaseDtuMax(int databaseDtuMax);
}

/**
* The SQL Elastic Pool definition to set the number of shared DTU for elastic pool.
*/
interface WithDtu {
/**
* Creates a new SqlElasticPool resource under SQLServer.
* Sets the total shared DTU for the SQL Azure Database Elastic Pool.
*
* @param sqlServerCreatable a creatable definition for the SQLServer
* @return the creatable for the SQLDatabase
* @param dtu total shared DTU for the SQL Azure Database Elastic Pool
* @return The next stage of definition.
*/
Creatable<SqlElasticPool> withNewSqlServer(Creatable<SqlServer> sqlServerCreatable);
SqlElasticPool.DefinitionStages.WithCreate withDtu(int dtu);
}

/**
* The SQL Elastic Pool definition to set the storage limit for the SQL Azure Database Elastic Pool in MB.
*/
interface WithStorageCapacity {
/**
* Creates a new SqlElasticPool resource under SQLServer.
* Sets the storage limit for the SQL Azure Database Elastic Pool in MB.
*
* @param existingSqlServer the SQLServer under which this SqlElasticPool to be created.
* @return the creatable for the SQLDatabase
* @param storageMB storage limit for the SQL Azure Database Elastic Pool in MB
* @return The next stage of definition.
*/
Creatable<SqlElasticPool> withExistingSqlServer(SqlServer existingSqlServer);
SqlElasticPool.DefinitionStages.WithCreate withStorageCapacity(int storageMB);
}

/**
* A SQL Server definition with sufficient inputs to create a new
* SQL Server in the cloud, but exposing additional optional inputs to
* specify.
*/
interface WithCreate extends
WithSqlServer,
DefinitionWithTags<SqlElasticPool.DefinitionStages.WithCreate> {
Creatable<SqlElasticPool>,
DefinitionWithTags<WithCreate>,
WithDatabaseDtuMin,
WithDatabaseDtuMax,
WithDtu,
WithStorageCapacity {
}
}

/**
* The template for a SQLElasticPool update operation, containing all the settings that can be modified.
*/
interface Update extends
UpdateStages.WithDatabaseDtuMax,
UpdateStages.WithDatabaseDtuMin,
UpdateStages.WithDtu,
UpdateStages.WithStorageCapacity,
Appliable<SqlElasticPool> {
}

/**
* Grouping of all the SQLElasticPool update stages.
*/
interface UpdateStages {

/**
* The SQL Elastic Pool definition to set the minimum DTU for database.
*/
interface WithDatabaseDtuMin {
/**
* Sets the minimum DTU all SQL Azure Databases are guaranteed.
*
* @param databaseDtuMin minimum DTU for all SQL Azure databases
* @return The next stage of definition.
*/
Update withDatabaseDtuMin(int databaseDtuMin);
}

/**
* The SQL Elastic Pool definition to set the maximum DTU for one database.
*/
interface WithDatabaseDtuMax {
/**
* Sets the maximum DTU any one SQL Azure Database can consume.
*
* @param databaseDtuMax maximum DTU any one SQL Azure Database can consume
* @return The next stage of definition.
*/
Update withDatabaseDtuMax(int databaseDtuMax);
}

/**
* The SQL Elastic Pool definition to set the number of shared DTU for elastic pool.
*/
interface WithDtu {
/**
* Sets the total shared DTU for the SQL Azure Database Elastic Pool.
*
* @param dtu total shared DTU for the SQL Azure Database Elastic Pool
* @return The next stage of definition.
*/
Update withDtu(int dtu);
}

/**
* The SQL Elastic Pool definition to set the storage limit for the SQL Azure Database Elastic Pool in MB.
*/
interface WithStorageCapacity {
/**
* Sets the storage limit for the SQL Azure Database Elastic Pool in MB.
*
* @param storageMB storage limit for the SQL Azure Database Elastic Pool in MB
* @return The next stage of definition.
*/
Update withStorageCapacity(int storageMB);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByParent;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource;
Expand Down Expand Up @@ -61,4 +62,11 @@ public interface SqlElasticPools extends
* @return the list of SQLElasticPools in a SQLServer
*/
PagedList<SqlElasticPool> listBySqlServer(GroupableResource sqlServer);

/**
* Entry point to SQL ElasticPool management API, which already have the SQLServer specified.
*/
interface SqlElasticPoolsCreatable extends SqlElasticPools {
SqlElasticPool.DefinitionStages.Blank definedWithSqlServer(String resourceGroupName, String sqlServerName, String elasticPoolName, Region region);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public interface SqlServer extends
*/
FirewallRules firewallRules();


/**
* @return returns entry point to manage ElasticPools in SqlServer.
*/
ElasticPools elasticPools();

/**
* Entry point to access FirewallRules from the SQL Server.
*/
Expand Down Expand Up @@ -82,6 +88,42 @@ interface FirewallRules {
*/
void delete(String firewallRuleName);
}

/**
* Entry point to access FirewallRules from the SQL Server.
*/
interface ElasticPools {
/**
* Gets a particular elastic pool.
*
* @param elasticPoolName name of the elastic pool to get
* @return Returns the elastic pool rule with in the SQL Server
*/
SqlElasticPool get(String elasticPoolName);

/**
* Creates a new elastic pool in SQL Server.
*
* @param elasticPoolName name of the elastic pool to be created
* @return Returns a stage to specify arguments of the elastic pool
*/
SqlElasticPool.DefinitionStages.Blank define(String elasticPoolName);

/**
* Returns all the elastic pools for the server.
*
* @return list of elastic pools for the server.
*/
PagedList<SqlElasticPool> list();

/**
* Delete specified elastic pool in the server.
*
* @param elasticPoolName name of the elastic pool to delete
*/
void delete(String elasticPoolName);
}

/**************************************************************
* Fluent interfaces to provision a SqlServer
**************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* 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.implementation;

import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.resources.fluentcore.arm.Region;
import com.microsoft.azure.management.sql.SqlElasticPool;
import com.microsoft.azure.management.sql.SqlElasticPools;
import com.microsoft.azure.management.sql.SqlServer;

/**
* Implementation of SqlServer.FirewallRules, which enables the creating the firewall rules from the SQLServer directly.
*/
public class ElasticPoolsImpl implements SqlServer.ElasticPools {

private final String resourceGroupName;
private final String sqlServerName;
private final SqlElasticPools.SqlElasticPoolsCreatable elasticPools;
private final Region region;

ElasticPoolsImpl(ElasticPoolsInner innerCollection, SqlServerManager manager, String resourceGroupName, String sqlServerName, Region region) {
this.resourceGroupName = resourceGroupName;
this.sqlServerName = sqlServerName;
this.region = region;
this.elasticPools = new SqlElasticPoolsImpl(innerCollection, manager);
}

@Override
public SqlElasticPool get(String firewallRuleName) {
return this.elasticPools.getBySqlServer(this.resourceGroupName, this.sqlServerName, firewallRuleName);
}

@Override
public SqlElasticPool.DefinitionStages.Blank define(String firewallRuleName) {
return this.elasticPools.definedWithSqlServer(this.resourceGroupName, this.sqlServerName, firewallRuleName, this.region);
}

@Override
public PagedList<SqlElasticPool> list() {
return this.elasticPools.listBySqlServer(this.resourceGroupName, this.sqlServerName);
}

@Override
public void delete(String firewallRuleName) {
this.elasticPools.deleteByParent(this.resourceGroupName, this.sqlServerName, firewallRuleName);
}
}
Loading