Skip to content

Mkherani swagger #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 12, 2016
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 @@ -32,15 +32,16 @@ public interface IPsBackupProvider
{
void Initialize(Dictionary<System.Enum, object> providerData, ServiceClientAdapter serviceClientAdapter);

BaseRecoveryServicesJobResponse EnableProtection();
Microsoft.Rest.Azure.AzureOperationResponse EnableProtection();

BaseRecoveryServicesJobResponse DisableProtection();
Microsoft.Rest.Azure.AzureOperationResponse DisableProtection();

BaseRecoveryServicesJobResponse TriggerBackup();
Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup();

BaseRecoveryServicesJobResponse TriggerRestore();
Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore();

ProtectedItemResponse GetProtectedItem();
//ProtectedItemResponse GetProtectedItem();
ProtectedItemResource GetProtectedItem();

CmdletModel.RecoveryPointBase GetRecoveryPointDetails();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void Initialize(
this.ServiceClientAdapter = serviceClientAdapter;
}

public ServiceClientModel.BaseRecoveryServicesJobResponse EnableProtection()
public Microsoft.Rest.Azure.AzureOperationResponse EnableProtection()
{
throw new NotImplementedException();
}
Expand All @@ -71,7 +71,7 @@ public ServiceClientModel.BaseRecoveryServicesJobResponse EnableProtection()
/// Triggers the disable protection operation for the given item
/// </summary>
/// <returns>The job response returned from the service</returns>
public ServiceClientModel.BaseRecoveryServicesJobResponse DisableProtection()
public Microsoft.Rest.Azure.AzureOperationResponse DisableProtection()
{
bool deleteBackupData = (bool)ProviderData[ItemParams.DeleteBackupData];

Expand All @@ -96,17 +96,17 @@ public ServiceClientModel.BaseRecoveryServicesJobResponse DisableProtection()
}
}

public ServiceClientModel.BaseRecoveryServicesJobResponse TriggerBackup()
public Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup()
{
throw new NotImplementedException();
}

public ServiceClientModel.BaseRecoveryServicesJobResponse TriggerRestore()
public Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore()
{
throw new NotImplementedException();
}

public ServiceClientModel.ProtectedItemResponse GetProtectedItem()
public Microsoft.Rest.Azure.AzureOperationResponse GetProtectedItem()
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,27 @@ public void Initialize(Dictionary<System.Enum, object> providerData, ServiceClie
this.ServiceClientAdapter = serviceClientAdapter;
}

public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse EnableProtection()
public Microsoft.Rest.Azure.AzureOperationResponse EnableProtection()
{
throw new NotImplementedException();
}

public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse DisableProtection()
public Microsoft.Rest.Azure.AzureOperationResponse DisableProtection()
{
throw new NotImplementedException();
}

public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerBackup()
public Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup()
{
throw new NotImplementedException();
}

public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerRestore()
public Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore()
{
throw new NotImplementedException();
}

public Management.RecoveryServices.Backup.Models.ProtectedItemResponse GetProtectedItem()
public ServiceClientModel.ProtectedItemResource GetProtectedItem()
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
using Microsoft.Rest.Azure.OData;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -138,12 +139,9 @@ public Microsoft.Rest.Azure.AzureOperationResponse EnableProtection()
properties.PolicyId = policy.Id;
properties.SourceResourceId = sourceResourceId;

ProtectedItemCreateOrUpdateRequest serviceClientRequest = new ProtectedItemCreateOrUpdateRequest()
ProtectedItemResource serviceClientRequest = new ProtectedItemResource()
{
Item = new ProtectedItemResource()
{
Properties = properties,
}
Properties = properties
};

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

ItemBase itemBase = (ItemBase)
ProviderData[ItemParams.Item];
ItemBase itemBase = (ItemBase)ProviderData[ItemParams.Item];

AzureVmItem item = (AzureVmItem)
ProviderData[ItemParams.Item];
AzureVmItem item = (AzureVmItem)ProviderData[ItemParams.Item];
// do validations

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

ProtectedItemCreateOrUpdateRequest serviceClientRequest = new ProtectedItemCreateOrUpdateRequest()
ProtectedItemResource serviceClientRequest = new ProtectedItemResource()
{
Item = new ProtectedItemResource()
{
Properties = properties,
}
Properties = properties,
};

return ServiceClientAdapter.CreateOrUpdateProtectedItem(
Expand All @@ -231,6 +224,7 @@ public Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup()
IdUtils.GetValueByName(iaasVmItem.Id, IdUtils.IdNames.ProtectedItemName),
expiryDateTime);
}

/// <summary>
/// Triggers the recovery operation for the given recovery point
/// </summary>
Expand All @@ -249,7 +243,7 @@ public Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore()
return response;
}

public Microsoft.Rest.Azure.AzureOperationResponse GetProtectedItem()
public ProtectedItemResource GetProtectedItem()
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -311,12 +305,8 @@ public CmdletModel.RecoveryPointBase GetRecoveryPointDetails()
}

//we need to fetch the list of RPs
RecoveryPointQueryParameters queryFilter = new RecoveryPointQueryParameters();
queryFilter.StartDate = CommonHelpers.GetDateTimeStringForService(startDate);
queryFilter.EndDate = CommonHelpers.GetDateTimeStringForService(endDate);
RecoveryPointListResponse rpListResponse = null;

rpListResponse = ServiceClientAdapter.GetRecoveryPoints(containerUri, protectedItemName, queryFilter);
ODataQuery<BMSRPQueryObject> queryFilter = new ODataQuery<BMSRPQueryObject>(qObj => qObj.StartDate == startDate && qObj.EndDate == endDate);
List<RecoveryPointResource> rpListResponse = ServiceClientAdapter.GetRecoveryPoints(containerUri, protectedItemName, queryFilter);
return RecoveryPointConversions.GetPSAzureRecoveryPoints(rpListResponse, item);
}

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

ProtectedItemListQueryParam queryParams = new ProtectedItemListQueryParam();
queryParams.DatasourceType = ServiceClientModel.WorkloadType.VM;
queryParams.BackupManagementType = ServiceClientModel.BackupManagementType.AzureIaasVM.ToString();
ODataQuery<ProtectedItemQueryObject> queryParams = new ODataQuery<ProtectedItemQueryObject>(
q => q.BackupManagementType == ServiceClientModel.BackupManagementType.AzureIaasVM &&
q.ItemType == ServiceClientModel.WorkloadType.VM);

List<ProtectedItemResource> protectedItems = new List<ProtectedItemResource>();
string skipToken = null;
PaginationRequest paginationRequest = null;
do
{
var listResponse = ServiceClientAdapter.ListProtectedItem(queryParams, paginationRequest);
protectedItems.AddRange(listResponse.ItemList.Value);

ServiceClientHelpers.GetSkipTokenFromNextLink(listResponse.ItemList.NextLink, out skipToken);
if (skipToken != null)
{
paginationRequest = new PaginationRequest();
paginationRequest.SkipToken = skipToken;
}
} while (skipToken != null);
var listResponse = ServiceClientAdapter.ListProtectedItem(queryParams, skipToken);
protectedItems.AddRange(listResponse);

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

List<ProtectedItemResponse> protectedItemGetResponses = new List<ProtectedItemResponse>();
List<ProtectedItemResource> protectedItemGetResponses = new List<ProtectedItemResource>();

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

GetProtectedItemQueryParam getItemQueryParams = new GetProtectedItemQueryParam();
getItemQueryParams.Expand = "extendedinfo";
ODataQuery<GetProtectedItemQueryObject> getItemQueryParams = new ODataQuery<GetProtectedItemQueryObject>(
q => q.Expand == "extendedinfo");

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

var getResponse = ServiceClientAdapter.GetProtectedItem(containerUri, protectedItemUri, getItemQueryParams);
protectedItemGetResponses.Add(getResponse);
protectedItemGetResponses.Add(getResponse.Body);
}
}

Expand All @@ -606,13 +585,13 @@ public List<ItemBase> ListProtectedItems()
for (int i = 0; i < itemModels.Count; i++)
{
AzureVmItemExtendedInfo extendedInfo = new AzureVmItemExtendedInfo();
var serviceClientExtendedInfo = ((AzureIaaSVMProtectedItem)protectedItemGetResponses[i].Item.Properties).ExtendedInfo;
var serviceClientExtendedInfo = ((AzureIaaSVMProtectedItem)protectedItemGetResponses[i].Properties).ExtendedInfo;
if (serviceClientExtendedInfo.OldestRecoveryPoint.HasValue)
{
extendedInfo.OldestRecoveryPoint = serviceClientExtendedInfo.OldestRecoveryPoint;
}
extendedInfo.PolicyState = serviceClientExtendedInfo.PolicyInconsistent.ToString();
extendedInfo.RecoveryPointCount = serviceClientExtendedInfo.RecoveryPointCount;
extendedInfo.RecoveryPointCount = (int) (serviceClientExtendedInfo.RecoveryPointCount.HasValue? serviceClientExtendedInfo.RecoveryPointCount : 0);
((AzureVmItem)itemModels[i]).ExtendedInfo = extendedInfo;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ public void Initialize(Dictionary<System.Enum, object> providerData, ServiceClie
this.ServiceClientAdapter = serviceClientAdapter;
}

public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse EnableProtection()
public Microsoft.Rest.Azure.AzureOperationResponse EnableProtection()
{
throw new NotImplementedException();
}

public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse DisableProtection()
public Microsoft.Rest.Azure.AzureOperationResponse DisableProtection()
{
throw new NotImplementedException();
}

public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerBackup()
public Microsoft.Rest.Azure.AzureOperationResponse TriggerBackup()
{
throw new NotImplementedException();
}

public Management.RecoveryServices.Backup.Models.BaseRecoveryServicesJobResponse TriggerRestore()
public Microsoft.Rest.Azure.AzureOperationResponse TriggerRestore()
{
throw new NotImplementedException();
}

public Management.RecoveryServices.Backup.Models.ProtectedItemResponse GetProtectedItem()
public ProtectedItemResource GetProtectedItem()
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tempDll\Debug-Net45\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
<HintPath>..\..\..\tempDll\Debug-Net45\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Text;
using System.Web.Script.Serialization;
using System.Xml;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Management.RecoveryServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
// ----------------------------------------------------------------------------------

using System;
using System.IO;
using System.Runtime.Serialization;
using System.Xml;
using Hyak.Common;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.Azure.Commands.ResourceManager.Common;
using Newtonsoft.Json;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using System.Security.Cryptography;
using Microsoft.Azure.Portal.RecoveryServices.Models.Common;
using System.Collections.Generic;
using Microsoft.Azure.Management.RecoveryServices.Models;

namespace Microsoft.Azure.Commands.RecoveryServices
{
Expand Down