Skip to content

Commit 802687e

Browse files
committed
[Storage] move the table service properties API to table channel
1 parent 10f488a commit 802687e

15 files changed

+99
-83
lines changed

src/Storage/Storage.Test/Service/MockStorageBlobManagement.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -711,16 +711,6 @@ public Task<string> StartCopyAsync(CloudPageBlob blob, Uri source, PremiumPageBl
711711
throw new NotImplementedException();
712712
}
713713

714-
public Azure.Cosmos.Table.ServiceProperties GetStorageTableServiceProperties(XTable.TableRequestOptions options, XTable.OperationContext operationContext)
715-
{
716-
throw new NotImplementedException();
717-
}
718-
719-
public void SetStorageTableServiceProperties(Azure.Cosmos.Table.ServiceProperties properties, XTable.TableRequestOptions options, XTable.OperationContext operationContext)
720-
{
721-
throw new NotImplementedException();
722-
}
723-
724714
public AccountProperties GetAccountProperties()
725715
{
726716
throw new NotImplementedException();

src/Storage/Storage.Test/Service/MockStorageTableManagement.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,15 @@ public AzureStorageContext StorageContext
219219
{
220220
get { throw new NotImplementedException(); }
221221
}
222+
223+
public Azure.Cosmos.Table.ServiceProperties GetStorageTableServiceProperties(XTable.TableRequestOptions options, XTable.OperationContext operationContext)
224+
{
225+
throw new NotImplementedException();
226+
}
227+
228+
public void SetStorageTableServiceProperties(Azure.Cosmos.Table.ServiceProperties properties, XTable.TableRequestOptions options, XTable.OperationContext operationContext)
229+
{
230+
throw new NotImplementedException();
231+
}
222232
}
223233
}

src/Storage/Storage/Common/Cmdlet/GetAzureStorageCORSRule.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Linq;
2121
using System.Management.Automation;
2222
using System.Security.Permissions;
23+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
2324

2425
namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2526
{
@@ -50,7 +51,8 @@ public override void ExecuteCmdlet()
5051
}
5152
else //Table use old XSCL
5253
{
53-
XTable.ServiceProperties currentServiceProperties = Channel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
54+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
55+
XTable.ServiceProperties currentServiceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
5456
WriteObject(PSCorsRule.ParseCorsRules(currentServiceProperties.Cors));
5557
}
5658
}

src/Storage/Storage/Common/Cmdlet/GetAzureStorageServiceLogging.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2020
using System.Globalization;
2121
using System.Management.Automation;
2222
using System.Security.Permissions;
23+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
2324

2425
/// <summary>
2526
/// Show azure storage service properties
@@ -69,7 +70,8 @@ public override void ExecuteCmdlet()
6970
}
7071
else //Table use old XSCL
7172
{
72-
XTable.ServiceProperties serviceProperties = Channel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
73+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
74+
XTable.ServiceProperties serviceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
7375

7476
// Premium Account not support classic metrics and logging
7577
if (serviceProperties.Logging == null)

src/Storage/Storage/Common/Cmdlet/GetAzureStorageServiceMetrics.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2020
using System.Globalization;
2121
using System.Management.Automation;
2222
using System.Security.Permissions;
23+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
2324

2425
/// <summary>
2526
/// Show azure storage service properties
@@ -77,7 +78,8 @@ public override void ExecuteCmdlet()
7778
}
7879
else //Table use old XSCL
7980
{
80-
XTable.ServiceProperties serviceProperties = Channel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
81+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
82+
XTable.ServiceProperties serviceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
8183

8284
// Premium Account not support classic metrics and logging
8385
if ((MetricsType == ServiceMetricsType.Hour && serviceProperties.HourMetrics == null)

src/Storage/Storage/Common/Cmdlet/GetAzureStorageServiceProperties.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
1919
using System.Management.Automation;
2020
using System.Security.Permissions;
2121
using Microsoft.WindowsAzure.Commands.Storage.Model.ResourceModel;
22+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
2223

2324
/// <summary>
2425
/// Show Azure Storage service properties
@@ -52,7 +53,8 @@ public override void ExecuteCmdlet()
5253
}
5354
else //Table use old XSCL
5455
{
55-
XTable.ServiceProperties serviceProperties = Channel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
56+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
57+
XTable.ServiceProperties serviceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
5658
WriteObject(new PSSeriviceProperties(serviceProperties));
5759
}
5860
}

src/Storage/Storage/Common/Cmdlet/RemoveAzureStorageCORSRule.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using XTable = Microsoft.Azure.Cosmos.Table;
1717
using System.Management.Automation;
1818
using System.Security.Permissions;
19+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
1920

2021
namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2122
{
@@ -52,13 +53,14 @@ public override void ExecuteCmdlet()
5253
}
5354
else //Table use old XSCL
5455
{
55-
XTable.ServiceProperties currentServiceProperties = Channel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
56+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
57+
XTable.ServiceProperties currentServiceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
5658
XTable.ServiceProperties serviceProperties = new XTable.ServiceProperties();
5759
serviceProperties.Clean();
5860
serviceProperties.Cors = currentServiceProperties.Cors;
5961
serviceProperties.Cors.CorsRules.Clear();
6062

61-
Channel.SetStorageTableServiceProperties(serviceProperties,
63+
tableChannel.SetStorageTableServiceProperties(serviceProperties,
6264
GetTableRequestOptions(), TableOperationContext);
6365
}
6466
}

src/Storage/Storage/Common/Cmdlet/SetAzureStorageCORSRule.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Net;
2323
using System.Security.Permissions;
2424
using SharedProtocol = Microsoft.WindowsAzure.Storage.Shared.Protocol;
25+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
2526

2627
namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2728
{
@@ -113,7 +114,8 @@ public override void ExecuteCmdlet()
113114

114115
try
115116
{
116-
Channel.SetStorageTableServiceProperties(serviceProperties,
117+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
118+
tableChannel.SetStorageTableServiceProperties(serviceProperties,
117119
GetTableRequestOptions(), TableOperationContext);
118120
}
119121
catch (XTable.StorageException se)

src/Storage/Storage/Common/Cmdlet/SetAzureStorageServiceLogging.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
1616
{
17+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
1718
using Microsoft.WindowsAzure.Storage.Shared.Protocol;
1819
using System;
1920
using System.Globalization;
@@ -255,7 +256,8 @@ public override void ExecuteCmdlet()
255256
}
256257
else //Table use old XSCL
257258
{
258-
XTable.ServiceProperties currentServiceProperties = Channel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
259+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
260+
XTable.ServiceProperties currentServiceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
259261

260262
// Premium Account not support classic metrics and logging
261263
if (currentServiceProperties.Logging == null)
@@ -273,7 +275,7 @@ public override void ExecuteCmdlet()
273275

274276
UpdateTableServiceProperties(serviceProperties.Logging);
275277

276-
Channel.SetStorageTableServiceProperties(serviceProperties,
278+
tableChannel.SetStorageTableServiceProperties(serviceProperties,
277279
GetTableRequestOptions(), TableOperationContext);
278280

279281
if (PassThru)

src/Storage/Storage/Common/Cmdlet/SetAzureStorageServiceMetrics.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2020
using System.Globalization;
2121
using System.Management.Automation;
2222
using System.Security.Permissions;
23+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
2324

2425
/// <summary>
2526
/// Show azure storage service properties
@@ -213,7 +214,8 @@ public override void ExecuteCmdlet()
213214
}
214215
else //Table use old XSCL
215216
{
216-
XTable.ServiceProperties currentServiceProperties = Channel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
217+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
218+
XTable.ServiceProperties currentServiceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
217219

218220
// Premium Account not support classic metrics and logging
219221
if ((MetricsType == ServiceMetricsType.Hour && currentServiceProperties.HourMetrics == null)
@@ -245,7 +247,7 @@ public override void ExecuteCmdlet()
245247
break;
246248
}
247249

248-
Channel.SetStorageTableServiceProperties(serviceProperties,
250+
tableChannel.SetStorageTableServiceProperties(serviceProperties,
249251
GetTableRequestOptions(), TableOperationContext);
250252

251253
if (PassThru)

src/Storage/Storage/Common/Cmdlet/SetAzureStorageServiceProperties.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet
2020
using StorageClient = WindowsAzure.Storage.Shared.Protocol;
2121
using XTable = Microsoft.Azure.Cosmos.Table;
2222
using Microsoft.WindowsAzure.Commands.Storage.Model.ResourceModel;
23+
using Microsoft.WindowsAzure.Commands.Storage.Model.Contract;
2324

2425
/// <summary>
2526
/// Modify Azure Storage service properties
@@ -71,14 +72,15 @@ public override void ExecuteCmdlet()
7172
}
7273
else //Table use old XSCL
7374
{
74-
XTable.ServiceProperties serviceProperties = Channel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
75+
StorageTableManagement tableChannel = new StorageTableManagement(Channel.StorageContext);
76+
XTable.ServiceProperties serviceProperties = tableChannel.GetStorageTableServiceProperties(GetTableRequestOptions(), TableOperationContext);
7577

7678
if (!string.IsNullOrEmpty(DefaultServiceVersion))
7779
{
7880
serviceProperties.DefaultServiceVersion = this.DefaultServiceVersion;
7981
}
8082

81-
Channel.SetStorageTableServiceProperties(serviceProperties,
83+
tableChannel.SetStorageTableServiceProperties(serviceProperties,
8284
GetTableRequestOptions(), TableOperationContext);
8385

8486
if (PassThru)

src/Storage/Storage/Model/Contract/IStorageBlobManagement.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -431,24 +431,6 @@ BlobResultSegment ListBlobsSegmented(CloudBlobContainer container, string prefix
431431
BlobListingDetails blobListingDetails, int? maxResults, BlobContinuationToken currentToken,
432432
BlobRequestOptions options, OperationContext operationContext);
433433

434-
/// <summary>
435-
/// Get the Table service properties
436-
/// </summary>
437-
/// <param name="account">Cloud storage account</param>
438-
/// <param name="options">Request options</param>
439-
/// <param name="operationContext">Operation context</param>
440-
/// <returns>The service properties of the specified service type</returns>
441-
XTable.ServiceProperties GetStorageTableServiceProperties(XTable.TableRequestOptions options, XTable.OperationContext operationContext);
442-
443-
/// <summary>
444-
/// Set Table service properties
445-
/// </summary>
446-
/// <param name="account">Cloud storage account</param>
447-
/// <param name="properties">Service properties</param>
448-
/// <param name="options">Request options</param>
449-
/// <param name="operationContext">Operation context</param>
450-
void SetStorageTableServiceProperties(XTable.ServiceProperties properties, XTable.TableRequestOptions options, XTable.OperationContext operationContext);
451-
452434
/// <summary>
453435
/// Returns the sku name and account kind for the specified account
454436
/// </summary>

src/Storage/Storage/Model/Contract/IStorageTableManagement.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,23 @@ public interface IStorageTableManagement : IStorageManagement
103103
/// <param name="operationContext">context</param>
104104
/// <returns></returns>
105105
Task SetTablePermissionsAsync(CloudTable table, TablePermissions tablePermissions, TableRequestOptions requestOptions = null, XTable.OperationContext operationContext = null);
106+
107+
/// <summary>
108+
/// Get the Table service properties
109+
/// </summary>
110+
/// <param name="account">Cloud storage account</param>
111+
/// <param name="options">Request options</param>
112+
/// <param name="operationContext">Operation context</param>
113+
/// <returns>The service properties of the specified service type</returns>
114+
XTable.ServiceProperties GetStorageTableServiceProperties(XTable.TableRequestOptions options, XTable.OperationContext operationContext);
115+
116+
/// <summary>
117+
/// Set Table service properties
118+
/// </summary>
119+
/// <param name="account">Cloud storage account</param>
120+
/// <param name="properties">Service properties</param>
121+
/// <param name="options">Request options</param>
122+
/// <param name="operationContext">Operation context</param>
123+
void SetStorageTableServiceProperties(XTable.ServiceProperties properties, XTable.TableRequestOptions options, XTable.OperationContext operationContext);
106124
}
107125
}

src/Storage/Storage/Model/Contract/StorageBlobManagement.cs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -521,48 +521,6 @@ public void SetStorageServiceProperties(StorageServiceType type, XSCLProtocol.Se
521521
}
522522
}
523523

524-
525-
526-
/// <summary>
527-
/// Get the Table service properties
528-
/// </summary>
529-
/// <param name="account">Cloud storage account</param>
530-
/// <param name="options">Request options</param>
531-
/// <param name="operationContext">Operation context</param>
532-
/// <returns>The service properties of the specified service type</returns>
533-
public XTable.ServiceProperties GetStorageTableServiceProperties(XTable.TableRequestOptions options, XTable.OperationContext operationContext)
534-
{
535-
XTable.CloudStorageAccount account = StorageContext.TableStorageAccount;
536-
try
537-
{
538-
return account.CreateCloudTableClient().GetServicePropertiesAsync(options, operationContext).Result;
539-
}
540-
catch (AggregateException e) when (e.InnerException is XTable.StorageException)
541-
{
542-
throw e.InnerException;
543-
}
544-
}
545-
546-
/// <summary>
547-
/// Set Table service properties
548-
/// </summary>
549-
/// <param name="account">Cloud storage account</param>
550-
/// <param name="properties">Service properties</param>
551-
/// <param name="options">Request options</param>
552-
/// <param name="operationContext">Operation context</param>
553-
public void SetStorageTableServiceProperties(XTable.ServiceProperties properties, XTable.TableRequestOptions options, XTable.OperationContext operationContext)
554-
{
555-
XTable.CloudStorageAccount account = StorageContext.TableStorageAccount;
556-
try
557-
{
558-
Task.Run(() => account.CreateCloudTableClient().SetServicePropertiesAsync(properties, options, operationContext)).Wait();
559-
}
560-
catch (AggregateException e) when (e.InnerException is XTable.StorageException)
561-
{
562-
throw e.InnerException;
563-
}
564-
}
565-
566524
/// <summary>
567525
/// Get the SAS token for an account.
568526
/// </summary>

src/Storage/Storage/Model/Contract/StorageTableManagement.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,45 @@ public Task SetTablePermissionsAsync(CloudTable table, TablePermissions tablePer
215215
{
216216
return table.SetPermissionsAsync(tablePermissions, requestOptions, operationContext);
217217
}
218+
219+
/// <summary>
220+
/// Get the Table service properties
221+
/// </summary>
222+
/// <param name="account">Cloud storage account</param>
223+
/// <param name="options">Request options</param>
224+
/// <param name="operationContext">Operation context</param>
225+
/// <returns>The service properties of the specified service type</returns>
226+
public XTable.ServiceProperties GetStorageTableServiceProperties(XTable.TableRequestOptions options, XTable.OperationContext operationContext)
227+
{
228+
XTable.CloudStorageAccount account = StorageContext.TableStorageAccount;
229+
try
230+
{
231+
return account.CreateCloudTableClient().GetServicePropertiesAsync(options, operationContext).Result;
232+
}
233+
catch (AggregateException e) when (e.InnerException is XTable.StorageException)
234+
{
235+
throw e.InnerException;
236+
}
237+
}
238+
239+
/// <summary>
240+
/// Set Table service properties
241+
/// </summary>
242+
/// <param name="account">Cloud storage account</param>
243+
/// <param name="properties">Service properties</param>
244+
/// <param name="options">Request options</param>
245+
/// <param name="operationContext">Operation context</param>
246+
public void SetStorageTableServiceProperties(XTable.ServiceProperties properties, XTable.TableRequestOptions options, XTable.OperationContext operationContext)
247+
{
248+
XTable.CloudStorageAccount account = StorageContext.TableStorageAccount;
249+
try
250+
{
251+
Task.Run(() => account.CreateCloudTableClient().SetServicePropertiesAsync(properties, options, operationContext)).Wait();
252+
}
253+
catch (AggregateException e) when (e.InnerException is XTable.StorageException)
254+
{
255+
throw e.InnerException;
256+
}
257+
}
218258
}
219259
}

0 commit comments

Comments
 (0)