Skip to content

Commit

Permalink
Added elastic pool with create experience for the SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
anudeepsharma committed Oct 20, 2016
1 parent 1fc4ca8 commit 445ec96
Show file tree
Hide file tree
Showing 12 changed files with 739 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public FluentModelImplT withExistingParentResource(String groupName, String pare
public FluentModelImplT withExistingParentResource(FluentParentModelT existingParentResource) {
this.inner().withLocation(existingParentResource.regionName());
return withExistingParentResource(existingParentResource.resourceGroupName(), existingParentResource.name());

}

@Override
Expand All @@ -175,7 +174,9 @@ public FluentModelImplT withNewParentResource(Creatable<FluentParentModelT> pare

@Override
public void setInner(InnerModelT inner) {
this.parentName = ResourceId.parseResourceId(inner.id()).name();
if (inner.id() != null) {
this.parentName = ResourceId.parseResourceId(inner.id()).parent().name();
}
super.setInner(inner);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class IndexableRefreshableWrapperImpl<FluentModelT, InnerModelT>

private InnerModelT innerObject;
protected IndexableRefreshableWrapperImpl(InnerModelT innerObject) {
this.innerObject = innerObject;
this.setInner(innerObject);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.resources.fluentcore.arm.models.IndependentChildResource;
import com.microsoft.azure.management.resources.fluentcore.model.Appliable;
import com.microsoft.azure.management.resources.fluentcore.model.Creatable;
import com.microsoft.azure.management.resources.fluentcore.model.Refreshable;
import com.microsoft.azure.management.resources.fluentcore.model.Updatable;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;
Expand All @@ -25,7 +26,7 @@


/**
* An immutable client-side representation of an Azure SQL Server.
* An immutable client-side representation of an Azure SQL Database.
*/
@Fluent
public interface SqlDatabase extends
Expand All @@ -35,7 +36,7 @@ public interface SqlDatabase extends
Wrapper<DatabaseInner> {

/**
* @return the SQL Server name in which this database resides.
* @return the SQL Server name to which this database belongs
*/
String sqlServerName();

Expand Down Expand Up @@ -188,19 +189,71 @@ interface WithEdition {
interface WithElasticPoolName {
/**
* Sets the existing elastic pool for the SQLDatabase.
* @param elasticPoolName of for the SQL Database.
* @param elasticPoolName for the SQL Database.
* @return The next stage of definition.
*/
WithCreate withExistingElasticPoolName(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);

/**
* 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);
}

/**
* A resource definition allowing SQLServer to be attached with SQLDatabase.
*/
interface WithSqlServer {
/**
* Creates a new database resource under SQLServer.
*
* @param groupName the name of the resource group for SQLServer.
* @param sqlServerName the name of the sQLServer.
* @return the creatable for the child resource
*/
Creatable<SqlDatabase> withExistingSqlServer(String groupName, String sqlServerName);

/**
* Creates a new database resource under SQLServer.
*
* @param sqlServerCreatable a creatable definition for the SQLServer
* @return the creatable for the SQLDatabase
*/
Creatable<SqlDatabase> withNewSqlServer(Creatable<SqlServer> sqlServerCreatable);

/**
* Creates a new database resource under SQLServer.
*
* @param existingSqlServer the SQLServer under which this database to be created.
* @return the creatable for the SQLDatabase
*/
Creatable<SqlDatabase> withExistingSqlServer(SqlServer existingSqlServer);
}

/**
* A SQL Server definition with sufficient inputs to create a new
* A SQL Database definition with sufficient inputs to create a new
* SQL Server in the cloud, but exposing additional optional inputs to
* specify.
*/
interface WithCreate extends
IndependentChildResource.DefinitionStages.WithParentResource<SqlDatabase, SqlServer>,
WithSqlServer,
DefinitionWithTags<WithCreate>,
WithElasticPoolName {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/**
* 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.resources.fluentcore.arm.models.IndependentChildResource;
import com.microsoft.azure.management.resources.fluentcore.model.Appliable;
import com.microsoft.azure.management.resources.fluentcore.model.Creatable;
import com.microsoft.azure.management.resources.fluentcore.model.Refreshable;
import com.microsoft.azure.management.resources.fluentcore.model.Updatable;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;
import com.microsoft.azure.management.sql.implementation.ElasticPoolInner;
import org.joda.time.DateTime;

/**
* An immutable client-side representation of an Azure SQL ElasticPool.
*/
public interface SqlElasticPool extends
IndependentChildResource,
Refreshable<SqlElasticPool>,
Updatable<SqlElasticPool.Update>,
Wrapper<ElasticPoolInner> {

/**
* @return the SQL Server name to which this elastic pool belongs
*/
String sqlServerName();

/**
* @return the creation date of the Azure SQL Elastic Pool
*/
DateTime creationDate();

/**
* @return the state of the Azure SQL Elastic Pool
*/
String state();

/**
* @return the edition of Azure SQL Elastic Pool
*/
ElasticPoolEditions edition();

/**
* @return The total shared DTU for the SQL Azure Database Elastic Pool
*/
int dtu();


/**
* @return the maximum DTU any one SQL Azure database can consume.
*/
int databaseDtuMax();

/**
* @return the minimum DTU all SQL Azure Databases are guaranteed
*/
int databaseDtuMin();

/**
* @return the storage limit for the SQL Azure Database Elastic Pool in MB
*/
int storageMB();

/**
* Container interface for all the definitions that need to be implemented.
*/
interface Definition extends
DefinitionStages.Blank,
DefinitionStages.WithEdition,
DefinitionStages.WithCreate {

}

/**
* Grouping of all the storage account definition stages.
*/
interface DefinitionStages {
/**
* The first stage of the SQL Server definition.
*/
interface Blank extends SqlElasticPool.DefinitionStages.WithEdition {
}

/**
* The SQL Elastic Pool definition to set the edition for database.
*/
interface WithEdition {
/**
* Sets the edition for the SQL Elastic Pool.
* @param edition edition to be set for elastic pool.
* @return The next stage of definition.
*/
SqlElasticPool.DefinitionStages.WithCreate withEdition(ElasticPoolEditions edition);
}

/**
* A resource definition allowing SQLServer to be attached with SQLDatabase.
*/
interface WithSqlServer {
/**
* Creates a new SqlElasticPool resource under SQLServer.
*
* @param groupName the name of the resource group for SQLServer.
* @param sqlServerName the name of the sQLServer.
* @return the creatable for the child resource
*/
Creatable<SqlElasticPool> withExistingSqlServer(String groupName, String sqlServerName);

/**
* Creates a new SqlElasticPool resource under SQLServer.
*
* @param sqlServerCreatable a creatable definition for the SQLServer
* @return the creatable for the SQLDatabase
*/
Creatable<SqlElasticPool> withNewSqlServer(Creatable<SqlServer> sqlServerCreatable);

/**
* Creates a new SqlElasticPool resource under SQLServer.
*
* @param existingSqlServer the SQLServer under which this SqlElasticPool to be created.
* @return the creatable for the SQLDatabase
*/
Creatable<SqlElasticPool> withExistingSqlServer(SqlServer existingSqlServer);
}
/**
* 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> {
}
}

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

/**
* Grouping of all the SQLElasticPool update stages.
*/
interface UpdateStages {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* 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.PagedList;
import com.microsoft.azure.management.apigeneration.Fluent;
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;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting;

/**
* Entry point to SQL Elastic Pool management API.
*/
@Fluent
public interface SqlElasticPools extends
SupportsCreating<SqlElasticPool.DefinitionStages.Blank>,
SupportsDeleting,
SupportsGettingById<SqlElasticPool>,
SupportsBatchCreation<SqlElasticPool>,
SupportsDeletingByParent<SqlElasticPool> {

/**
* Gets the SQLElasticPool based on the resource group name, SQLServer name and SQLElasticPool name.
*
* @param resourceGroup the name of resource group.
* @param sqlServerName the name of SQLServer.
* @param name the name of SQLElasticPool.
* @return an immutable representation of the SQLElasticPool
*/
SqlElasticPool getBySqlServer(String resourceGroup, String sqlServerName, String name);

/**
* Gets the SQLElasticPool based on the SQLServer instance and SQLElasticPool name.
*
* @param sqlServer the instance of SQLServer.
* @param name the name of SQLElasticPool
* @return an immutable representation of the SQLElasticPool
*/
SqlElasticPool getBySqlServer(GroupableResource sqlServer, String name);

/**
* Lists resources of the specified type in the specified resource group and SQLServer.
*
* @param resourceGroupName the name of the resource group to list the resources from
* @param sqlServerName the name of SQLServer
* @return the list of SQLElasticPools in a SQLServer
*/
PagedList<SqlElasticPool> listBySqlServer(String resourceGroupName, String sqlServerName);

/**
* Gets the SQLElasticPool based on the SQLServer.
*
* @param sqlServer the instance of SQLServer
* @return the list of SQLElasticPools in a SQLServer
*/
PagedList<SqlElasticPool> listBySqlServer(GroupableResource sqlServer);
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,10 @@ interface WithAdminUserName {
* A SQL Server definition setting admin user password.
*/
interface WithPassword {
WithVersion withPassword(String password);
WithCreate withPassword(String password);
}

/**
* TODO - ans - Remove this if this is optional. Currently from REST APIs if I don't pass it then it
* it became 2.0.
* A SQL Server definition setting version.
*/
interface WithVersion {
Expand All @@ -105,7 +103,8 @@ interface WithVersion {
*/
interface WithCreate extends
Creatable<SqlServer>,
DefinitionWithTags<WithCreate> {
DefinitionWithTags<WithCreate>,
WithVersion {
}
}
/**
Expand Down
Loading

0 comments on commit 445ec96

Please sign in to comment.