Skip to content

Commit

Permalink
Merge pull request Azure#16 from huangpf/crp2
Browse files Browse the repository at this point in the history
Crp2
  • Loading branch information
AzureRT committed Jan 7, 2015
2 parents de1e95e + 161fe18 commit 05d53cd
Show file tree
Hide file tree
Showing 36 changed files with 6,298 additions and 481 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<package id="Microsoft.Azure.Gallery" version="2.2.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Graph.RBAC" version="1.4.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.11.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="1.0.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.7.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Monitoring" version="2.2.0-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ private void ParameterValidation()
ErrorCategory.InvalidArgument,
null));
}

// The API doesn't allow supplying a database name and and operation GUID.
if (this.MyInvocation.BoundParameters.ContainsKey("DatabaseName") &&
this.MyInvocation.BoundParameters.ContainsKey("OperationGuid"))
{
this.WriteError(new ErrorRecord(
new PSArgumentException(
String.Format(Resources.InvalidParameterCombination, "DatabaseName", "OperationGuid")),
string.Empty,
ErrorCategory.InvalidArgument,
null));
}

// The API doesn't allow supplying a database name and and operation GUID.
if (this.MyInvocation.BoundParameters.ContainsKey("Database") &&
this.MyInvocation.BoundParameters.ContainsKey("OperationGuid"))
{
this.WriteError(new ErrorRecord(
new PSArgumentException(
String.Format(Resources.InvalidParameterCombination, "Database", "OperationGuid")),
string.Empty,
ErrorCategory.InvalidArgument,
null));
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public Database CreateNewDatabase(
}

SqlCollationCheck(databaseCollation);

commandText = string.Format(
commandText,
SqlEscape(databaseName),
Expand Down Expand Up @@ -413,21 +413,21 @@ public Database CreateNewDatabase(
/// <param name="databaseCollation">The string to verify</param>
private void SqlCollationCheck(string databaseCollation)
{
if(string.IsNullOrEmpty (databaseCollation))
if (string.IsNullOrEmpty(databaseCollation))
{
return;
}

bool isValid = databaseCollation.All( (c) =>
bool isValid = databaseCollation.All((c) =>
{
if(!char.IsLetterOrDigit(c) && c != '_')
if (!char.IsLetterOrDigit(c) && c != '_')
{
return false;
}
return true;
});

if(!isValid)
if (!isValid)
{
throw new ArgumentException("Invalid Collation", "Collation");
}
Expand Down Expand Up @@ -555,58 +555,85 @@ public ServiceObjective[] GetServiceObjectives()
{
Context = this,
Enabled = true,
Id = new Guid("dd6d99bb-f193-4ec1-86f2-43d3bccbc49c "),
IsDefault = true,
Id = new Guid("26E021DB-F1F9-4C98-84C6-92AF8EF433D7"),
IsDefault = false,
IsSystem = true,
Name = "System"
},
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("620323BF-2879-4807-B30D-C2E6D7B3B3AA"),
IsDefault = false,
IsSystem = true,
Name = "System2"
},
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("dd6d99bb-f193-4ec1-86f2-43d3bccbc49c"),
IsDefault = false,
IsSystem = false,
Name = "Basic"
},
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("f1173c43-91bd-4aaa-973c-54e79e15235b "),
IsDefault = false,
Id = new Guid("f1173c43-91bd-4aaa-973c-54e79e15235b"),
IsDefault = true,
IsSystem = false,
Name = "S0"
},
new ServiceObjective()
{
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("1b1ebd4d-d903-4baa-97f9-4ea675f5e928 "),
Id = new Guid("1b1ebd4d-d903-4baa-97f9-4ea675f5e928"),
IsDefault = false,
IsSystem = false,
Name = "S1"
},
new ServiceObjective()
{
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("455330e1-00cd-488b-b5fa-177c226f28b7"),
IsDefault = false,
IsSystem = false,
Name = "S2"
},
new ServiceObjective()
{
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("789681B8-CA10-4EB0-BDF2-E0B050601B40"),
IsDefault = false,
IsSystem = false,
Name = "S3"
},
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("7203483a-c4fb-4304-9e9f-17c71c904f5d "),
Id = new Guid("7203483a-c4fb-4304-9e9f-17c71c904f5d"),
IsDefault = false,
IsSystem = false,
Name = "P1"
},
new ServiceObjective()
{
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("a7d1b92d-c987-4375-b54d-2b1d0e0f5bb0 "),
Id = new Guid("a7d1b92d-c987-4375-b54d-2b1d0e0f5bb0"),
IsDefault = false,
IsSystem = false,
Name = "P2"
},
new ServiceObjective()
{
new ServiceObjective()
{
Context = this,
Enabled = true,
Id = new Guid("a7c4c615-cfb1-464b-b252-925be0a19446"),
Expand Down Expand Up @@ -756,8 +783,8 @@ private void GetDatabaseProperties(Database db)
string commandText =
"SELECT " +
"DatabasePropertyEx(@name, 'Edition') as edition, " +
"DatabasePropertyEx(@name, 'ServiceObjective') as serviceObjective, " +
"DatabasePropertyEx(@name, 'MaxSizeInBytes') as maxSizeBytes";
//TODO: need to get current SLO here.

builder["Database"] = db.Name;
using (var connection = CreateConnection())
Expand All @@ -776,8 +803,9 @@ private void GetDatabaseProperties(Database db)
{
while (reader.Read())
{
db.MaxSizeBytes = (long)reader["maxSizeBytes"];
db.Edition = (string)reader["edition"];
db.MaxSizeBytes = ConvertFromDbValue<long>(reader["maxSizeBytes"]);
db.Edition = ConvertFromDbValue<string>(reader["edition"]);
db.ServiceObjectiveName = ConvertFromDbValue<string>(reader["serviceObjective"]);
}
}
}
Expand All @@ -787,6 +815,11 @@ private void GetDatabaseProperties(Database db)
{
db.MaxSizeGB = (int)(db.MaxSizeBytes / (1024 * 1024 * 1024));
}
if (!string.IsNullOrEmpty(db.ServiceObjectiveName))
{
db.ServiceObjective = GetServiceObjective(db.ServiceObjectiveName);
db.ServiceObjectiveId = db.ServiceObjective.Id;
}

builder["Database"] = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,14 @@
<Compile Include="Service\MockStorageQueueManagement.cs" />
<Compile Include="Service\MockStorageTableManagement.cs" />
<Compile Include="StorageTestBase.cs" />
<Compile Include="Table\GetAzureStorageTableStoredAccessPolicyTest.cs" />
<Compile Include="Table\GetAzureStorageTableTest.cs" />
<Compile Include="Table\NewAzureStorageTableSasTest.cs" />
<Compile Include="Table\NewAzureStorageTableStoredAccessPolicyTest.cs" />
<Compile Include="Table\NewAzureStorageTableTest.cs" />
<Compile Include="Table\RemoveAzureStorageTableStoredAccessPolicyTest.cs" />
<Compile Include="Table\RemoveAzureStorageTableTest.cs" />
<Compile Include="Table\SetAzureStorageTableStoredAccessPolicyTest.cs" />
<Compile Include="Table\StorageTableStorageTestBase.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Commands.Common.Storage;
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
using Microsoft.WindowsAzure.Storage;
Expand Down Expand Up @@ -158,6 +159,16 @@ public QueuePermissions GetPermissions(CloudQueue queue, QueueRequestOptions opt
throw new NotImplementedException();
}

public Task<QueuePermissions> GetPermissionsAsync(CloudQueue queue, QueueRequestOptions requestOptions, OperationContext operationContext)
{
throw new NotImplementedException();
}

public void SetPermissions(CloudQueue queue, QueuePermissions queuePermissions, QueueRequestOptions requestOptions, OperationContext operationContext)
{
throw new NotImplementedException();
}

public AzureStorageContext StorageContext
{
get { throw new NotImplementedException(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Commands.Common.Storage;
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
using Microsoft.WindowsAzure.Storage;
Expand All @@ -31,6 +32,11 @@ public class MockStorageTableManagement : IStorageTableManagement
/// </summary>
public List<CloudTable> tableList = new List<CloudTable>();

/// <summary>
/// Exists permissions
/// </summary>
public TablePermissions tablePermissions = new TablePermissions();

/// <summary>
/// Table end point
/// </summary>
Expand Down Expand Up @@ -166,7 +172,46 @@ public bool DoesTableExist(CloudTable table, TableRequestOptions requestOptions,
/// <returns>Table permission</returns>
public TablePermissions GetTablePermissions(CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
{
throw new NotImplementedException();
return this.tablePermissions;
}

/// <summary>
/// Set table permission
/// </summary>
/// <param name="table">Cloud table object</param>
/// <param name="tablePermissions">table permissions</param>
/// <param name="requestOptions">Table request options</param>
/// <param name="operationContext">Operation context</param>
/// <returns></returns>
public void SetTablePermissions(CloudTable table, TablePermissions tablePermissions, TableRequestOptions requestOptions, OperationContext operationContext)
{
this.tablePermissions = tablePermissions;
}

/// <summary>
/// Return a task that asynchronously set table permissions
/// </summary>
/// <param name="table">target table</param>
/// <param name="tablePermissions">permissions to set</param>
/// <param name="requestOptions">request options</param>
/// <param name="operationContext">context</param>
/// <returns></returns>
public Task SetTablePermissionsAsync(CloudTable table, TablePermissions tablePermissions, TableRequestOptions requestOptions, OperationContext operationContext)
{
return Task.Factory.StartNew(() => this.SetTablePermissions(table, tablePermissions, requestOptions, operationContext));
}

/// <summary>
/// Return a task that asynchronously fetch table permissions
/// </summary>
/// <param name="table">target table</param>
/// <param name="requestOptions">request options</param>
/// <param name="operationContext">context</param>
/// <returns></returns>
public Task<TablePermissions> GetTablePermissionsAsync(CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext)
{
return Task.Factory.StartNew(() => this.GetTablePermissions(table,
requestOptions, operationContext));
}

public AzureStorageContext StorageContext
Expand Down
Loading

0 comments on commit 05d53cd

Please sign in to comment.