Skip to content

Commit 53cc8b1

Browse files
authored
Mkherani swagger (#351)
* Swagger Changes * Swagger changes. * SwaggerChanges in Provider sln * Swagger changes * swagger changes
1 parent b70b56c commit 53cc8b1

File tree

9 files changed

+46
-74
lines changed

9 files changed

+46
-74
lines changed

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/IPsBackupProvider.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ public interface IPsBackupProvider
3232
{
3333
void Initialize(Dictionary<System.Enum, object> providerData, ServiceClientAdapter serviceClientAdapter);
3434

35-
BaseRecoveryServicesJobResponse EnableProtection();
35+
Microsoft.Rest.Azure.AzureOperationResponse EnableProtection();
3636

37-
BaseRecoveryServicesJobResponse DisableProtection();
37+
Microsoft.Rest.Azure.AzureOperationResponse DisableProtection();
3838

39-
BaseRecoveryServicesJobResponse TriggerBackup();
39+
Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup();
4040

41-
BaseRecoveryServicesJobResponse TriggerRestore();
41+
Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore();
4242

43-
ProtectedItemResponse GetProtectedItem();
43+
//ProtectedItemResponse GetProtectedItem();
44+
ProtectedItemResource GetProtectedItem();
4445

4546
CmdletModel.RecoveryPointBase GetRecoveryPointDetails();
4647

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Providers/AzureSqlPsBackupProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void Initialize(
6262
this.ServiceClientAdapter = serviceClientAdapter;
6363
}
6464

65-
public ServiceClientModel.BaseRecoveryServicesJobResponse EnableProtection()
65+
public Microsoft.Rest.Azure.AzureOperationResponse EnableProtection()
6666
{
6767
throw new NotImplementedException();
6868
}
@@ -71,7 +71,7 @@ public ServiceClientModel.BaseRecoveryServicesJobResponse EnableProtection()
7171
/// Triggers the disable protection operation for the given item
7272
/// </summary>
7373
/// <returns>The job response returned from the service</returns>
74-
public ServiceClientModel.BaseRecoveryServicesJobResponse DisableProtection()
74+
public Microsoft.Rest.Azure.AzureOperationResponse DisableProtection()
7575
{
7676
bool deleteBackupData = (bool)ProviderData[ItemParams.DeleteBackupData];
7777

@@ -96,17 +96,17 @@ public ServiceClientModel.BaseRecoveryServicesJobResponse DisableProtection()
9696
}
9797
}
9898

99-
public ServiceClientModel.BaseRecoveryServicesJobResponse TriggerBackup()
99+
public Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup()
100100
{
101101
throw new NotImplementedException();
102102
}
103103

104-
public ServiceClientModel.BaseRecoveryServicesJobResponse TriggerRestore()
104+
public Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore()
105105
{
106106
throw new NotImplementedException();
107107
}
108108

109-
public ServiceClientModel.ProtectedItemResponse GetProtectedItem()
109+
public Microsoft.Rest.Azure.AzureOperationResponse GetProtectedItem()
110110
{
111111
throw new NotImplementedException();
112112
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Providers/DpmPsBackupProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,27 @@ public void Initialize(Dictionary<System.Enum, object> providerData, ServiceClie
4343
this.ServiceClientAdapter = serviceClientAdapter;
4444
}
4545

46-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse EnableProtection()
46+
public Microsoft.Rest.Azure.AzureOperationResponse EnableProtection()
4747
{
4848
throw new NotImplementedException();
4949
}
5050

51-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse DisableProtection()
51+
public Microsoft.Rest.Azure.AzureOperationResponse DisableProtection()
5252
{
5353
throw new NotImplementedException();
5454
}
5555

56-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerBackup()
56+
public Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup()
5757
{
5858
throw new NotImplementedException();
5959
}
6060

61-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerRestore()
61+
public Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore()
6262
{
6363
throw new NotImplementedException();
6464
}
6565

66-
public Management.RecoveryServices.Backup.Models.ProtectedItemResponse GetProtectedItem()
66+
public ServiceClientModel.ProtectedItemResource GetProtectedItem()
6767
{
6868
throw new NotImplementedException();
6969
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Providers/IaasVmPsBackupProvider.cs

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
1818
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
1919
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
20+
using Microsoft.Rest.Azure.OData;
2021
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2122
using System;
2223
using System.Collections.Generic;
@@ -138,12 +139,9 @@ public Microsoft.Rest.Azure.AzureOperationResponse EnableProtection()
138139
properties.PolicyId = policy.Id;
139140
properties.SourceResourceId = sourceResourceId;
140141

141-
ProtectedItemCreateOrUpdateRequest serviceClientRequest = new ProtectedItemCreateOrUpdateRequest()
142+
ProtectedItemResource serviceClientRequest = new ProtectedItemResource()
142143
{
143-
Item = new ProtectedItemResource()
144-
{
145-
Properties = properties,
146-
}
144+
Properties = properties
147145
};
148146

149147
return ServiceClientAdapter.CreateOrUpdateProtectedItem(
@@ -160,11 +158,9 @@ public Microsoft.Rest.Azure.AzureOperationResponse DisableProtection()
160158
{
161159
bool deleteBackupData = (bool)ProviderData[ItemParams.DeleteBackupData];
162160

163-
ItemBase itemBase = (ItemBase)
164-
ProviderData[ItemParams.Item];
161+
ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item];
165162

166-
AzureVmItem item = (AzureVmItem)
167-
ProviderData[ItemParams.Item];
163+
AzureVmItem item = (AzureVmItem)ProviderData[ItemParams.Item];
168164
// do validations
169165

170166
ValidateAzureVMDisableProtectionRequest(itemBase);
@@ -201,12 +197,9 @@ public Microsoft.Rest.Azure.AzureOperationResponse DisableProtection()
201197
properties.ProtectionState = ItemProtectionState.ProtectionStopped.ToString();
202198
properties.SourceResourceId = item.SourceResourceId;
203199

204-
ProtectedItemCreateOrUpdateRequest serviceClientRequest = new ProtectedItemCreateOrUpdateRequest()
200+
ProtectedItemResource serviceClientRequest = new ProtectedItemResource()
205201
{
206-
Item = new ProtectedItemResource()
207-
{
208-
Properties = properties,
209-
}
202+
Properties = properties,
210203
};
211204

212205
return ServiceClientAdapter.CreateOrUpdateProtectedItem(
@@ -231,6 +224,7 @@ public Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup()
231224
IdUtils.GetValueByName(iaasVmItem.Id, IdUtils.IdNames.ProtectedItemName),
232225
expiryDateTime);
233226
}
227+
234228
/// <summary>
235229
/// Triggers the recovery operation for the given recovery point
236230
/// </summary>
@@ -249,7 +243,7 @@ public Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore()
249243
return response;
250244
}
251245

252-
public Microsoft.Rest.Azure.AzureOperationResponse GetProtectedItem()
246+
public ProtectedItemResource GetProtectedItem()
253247
{
254248
throw new NotImplementedException();
255249
}
@@ -311,12 +305,8 @@ public CmdletModel.RecoveryPointBase GetRecoveryPointDetails()
311305
}
312306

313307
//we need to fetch the list of RPs
314-
RecoveryPointQueryParameters queryFilter = new RecoveryPointQueryParameters();
315-
queryFilter.StartDate = CommonHelpers.GetDateTimeStringForService(startDate);
316-
queryFilter.EndDate = CommonHelpers.GetDateTimeStringForService(endDate);
317-
RecoveryPointListResponse rpListResponse = null;
318-
319-
rpListResponse = ServiceClientAdapter.GetRecoveryPoints(containerUri, protectedItemName, queryFilter);
308+
ODataQuery<BMSRPQueryObject> queryFilter = new ODataQuery<BMSRPQueryObject>(qObj => qObj.StartDate == startDate && qObj.EndDate == endDate);
309+
List<RecoveryPointResource> rpListResponse = ServiceClientAdapter.GetRecoveryPoints(containerUri, protectedItemName, queryFilter);
320310
return RecoveryPointConversions.GetPSAzureRecoveryPoints(rpListResponse, item);
321311
}
322312

@@ -542,25 +532,14 @@ public List<ItemBase> ListProtectedItems()
542532
Models.WorkloadType workloadType =
543533
(Models.WorkloadType)this.ProviderData[ItemParams.WorkloadType];
544534

545-
ProtectedItemListQueryParam queryParams = new ProtectedItemListQueryParam();
546-
queryParams.DatasourceType = ServiceClientModel.WorkloadType.VM;
547-
queryParams.BackupManagementType = ServiceClientModel.BackupManagementType.AzureIaasVM.ToString();
535+
ODataQuery<ProtectedItemQueryObject> queryParams = new ODataQuery<ProtectedItemQueryObject>(
536+
q => q.BackupManagementType == ServiceClientModel.BackupManagementType.AzureIaasVM &&
537+
q.ItemType == ServiceClientModel.WorkloadType.VM);
548538

549539
List<ProtectedItemResource> protectedItems = new List<ProtectedItemResource>();
550540
string skipToken = null;
551-
PaginationRequest paginationRequest = null;
552-
do
553-
{
554-
var listResponse = ServiceClientAdapter.ListProtectedItem(queryParams, paginationRequest);
555-
protectedItems.AddRange(listResponse.ItemList.Value);
556-
557-
ServiceClientHelpers.GetSkipTokenFromNextLink(listResponse.ItemList.NextLink, out skipToken);
558-
if (skipToken != null)
559-
{
560-
paginationRequest = new PaginationRequest();
561-
paginationRequest.SkipToken = skipToken;
562-
}
563-
} while (skipToken != null);
541+
var listResponse = ServiceClientAdapter.ListProtectedItem(queryParams, skipToken);
542+
protectedItems.AddRange(listResponse);
564543

565544
// 1. Filter by container
566545
if (container != null)
@@ -573,7 +552,7 @@ public List<ItemBase> ListProtectedItems()
573552
}).ToList();
574553
}
575554

576-
List<ProtectedItemResponse> protectedItemGetResponses = new List<ProtectedItemResponse>();
555+
List<ProtectedItemResource> protectedItemGetResponses = new List<ProtectedItemResource>();
577556

578557
// 2. Filter by item's friendly name
579558
if (!string.IsNullOrEmpty(name))
@@ -585,8 +564,8 @@ public List<ItemBase> ListProtectedItems()
585564
return protectedItemUri.ToLower().Contains(name.ToLower());
586565
}).ToList();
587566

588-
GetProtectedItemQueryParam getItemQueryParams = new GetProtectedItemQueryParam();
589-
getItemQueryParams.Expand = "extendedinfo";
567+
ODataQuery<GetProtectedItemQueryObject> getItemQueryParams = new ODataQuery<GetProtectedItemQueryObject>(
568+
q => q.Expand == "extendedinfo");
590569

591570
for (int i = 0; i < protectedItems.Count; i++)
592571
{
@@ -595,7 +574,7 @@ public List<ItemBase> ListProtectedItems()
595574
string protectedItemUri = HelperUtils.GetProtectedItemUri(dictionary, protectedItems[i].Id);
596575

597576
var getResponse = ServiceClientAdapter.GetProtectedItem(containerUri, protectedItemUri, getItemQueryParams);
598-
protectedItemGetResponses.Add(getResponse);
577+
protectedItemGetResponses.Add(getResponse.Body);
599578
}
600579
}
601580

@@ -606,13 +585,13 @@ public List<ItemBase> ListProtectedItems()
606585
for (int i = 0; i < itemModels.Count; i++)
607586
{
608587
AzureVmItemExtendedInfo extendedInfo = new AzureVmItemExtendedInfo();
609-
var serviceClientExtendedInfo = ((AzureIaaSVMProtectedItem)protectedItemGetResponses[i].Item.Properties).ExtendedInfo;
588+
var serviceClientExtendedInfo = ((AzureIaaSVMProtectedItem)protectedItemGetResponses[i].Properties).ExtendedInfo;
610589
if (serviceClientExtendedInfo.OldestRecoveryPoint.HasValue)
611590
{
612591
extendedInfo.OldestRecoveryPoint = serviceClientExtendedInfo.OldestRecoveryPoint;
613592
}
614593
extendedInfo.PolicyState = serviceClientExtendedInfo.PolicyInconsistent.ToString();
615-
extendedInfo.RecoveryPointCount = serviceClientExtendedInfo.RecoveryPointCount;
594+
extendedInfo.RecoveryPointCount = (int) (serviceClientExtendedInfo.RecoveryPointCount.HasValue? serviceClientExtendedInfo.RecoveryPointCount : 0);
616595
((AzureVmItem)itemModels[i]).ExtendedInfo = extendedInfo;
617596
}
618597
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Providers/MabPsBackupProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,27 @@ public void Initialize(Dictionary<System.Enum, object> providerData, ServiceClie
4545
this.ServiceClientAdapter = serviceClientAdapter;
4646
}
4747

48-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse EnableProtection()
48+
public Microsoft.Rest.Azure.AzureOperationResponse EnableProtection()
4949
{
5050
throw new NotImplementedException();
5151
}
5252

53-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse DisableProtection()
53+
public Microsoft.Rest.Azure.AzureOperationResponse DisableProtection()
5454
{
5555
throw new NotImplementedException();
5656
}
5757

58-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerBackup()
58+
public Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup()
5959
{
6060
throw new NotImplementedException();
6161
}
6262

63-
public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerRestore()
63+
public Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore()
6464
{
6565
throw new NotImplementedException();
6666
}
6767

68-
public Management.RecoveryServices.Backup.Models.ProtectedItemResponse GetProtectedItem()
68+
public ProtectedItemResource GetProtectedItem()
6969
{
7070
throw new NotImplementedException();
7171
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup/Commands.RecoveryServices.Backup.Cmdlets.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<SpecificVersion>False</SpecificVersion>
6060
<HintPath>..\..\..\tempDll\Debug-Net45\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
6161
</Reference>
62+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
63+
<HintPath>..\..\..\tempDll\Debug-Net45\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
64+
</Reference>
6265
<Reference Include="Microsoft.WindowsAzure.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6366
<SpecificVersion>False</SpecificVersion>
6467
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Common/PSRecoveryServicesClient.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16-
using System.Collections.Generic;
1716
using System.Diagnostics.CodeAnalysis;
18-
using System.IO;
19-
using System.Net;
20-
using System.Runtime.Serialization;
21-
using System.Security.Cryptography;
22-
using System.Text;
23-
using System.Web.Script.Serialization;
24-
using System.Xml;
2517
using Microsoft.Azure.Commands.Common.Authentication;
2618
using Microsoft.Azure.Commands.Common.Authentication.Models;
2719
using Microsoft.Azure.Management.RecoveryServices;

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Common/RecoveryServicesCmdletBase.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16-
using System.IO;
1716
using System.Runtime.Serialization;
1817
using System.Xml;
1918
using Hyak.Common;
20-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2119
using Microsoft.Azure.Commands.ResourceManager.Common;
2220
using Newtonsoft.Json;
2321
using System.Text;

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Utilities/Utilities.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
using System.Security.Cryptography;
2020
using Microsoft.Azure.Portal.RecoveryServices.Models.Common;
2121
using System.Collections.Generic;
22-
using Microsoft.Azure.Management.RecoveryServices.Models;
2322

2423
namespace Microsoft.Azure.Commands.RecoveryServices
2524
{

0 commit comments

Comments
 (0)