Skip to content

Commit b248dd0

Browse files
committed
Merge pull request #18 from MabOneSdk/panbha3
Panbha3
2 parents 03afff0 + d78f8c2 commit b248dd0

File tree

9 files changed

+33
-16
lines changed

9 files changed

+33
-16
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public abstract class AzureBackupCmdletBase : AzurePSCmdlet
4141
/// </summary>
4242
private string resourceName { get; set; }
4343

44+
/// <summary>
45+
/// Resource context for the operation
46+
/// </summary>
47+
private string location { get; set; }
48+
4449
/// <summary>
4550
/// Client request id.
4651
/// </summary>
@@ -82,10 +87,11 @@ protected void RefreshClientRequestId()
8287
clientRequestId = Guid.NewGuid().ToString() + "-" + DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ssZ") + "-PS";
8388
}
8489

85-
public void InitializeAzureBackupCmdlet(string rgName, string rName)
90+
public void InitializeAzureBackupCmdlet(string rgName, string rName, string locationName)
8691
{
8792
resourceGroupName = rgName;
8893
resourceName = rName;
94+
location = locationName;
8995

9096
RefreshClientRequestId();
9197
WriteDebug(string.Format("Initialized AzureBackup Cmdlet, ClientRequestId: {0}, ResourceGroupName: {1}, ResourceName : {2}", this.clientRequestId, resourceGroupName, resourceName));

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletHelpMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal static class AzureBackupCmdletHelpMessage
2020
public const string PolicyName = "The protection policy name.";
2121
public const string ResourceGroupName = "The ResourceGroup name.";
2222
public const string ResourceName = "The Resource name.";
23+
public const string Location = "Location.";
2324
public const string TargetLocation = "The directory where the credentials file will be saved.";
2425
public const string ContainerResourceName = "The container resource name aka friendly name.";
2526
public const string ContainerId = "The container ID.";

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupDSCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override void ExecuteCmdlet()
4040

4141
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", item.ResourceGroupName, item.ResourceName));
4242

43-
InitializeAzureBackupCmdlet(item.ResourceGroupName, item.ResourceName);
43+
InitializeAzureBackupCmdlet(item.ResourceGroupName, item.ResourceName, item.Location);
4444
}
4545
}
4646
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupVaultCmdletBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ public abstract class AzureBackupVaultCmdletBase : AzureBackupCmdletBase
3636
[ValidateNotNullOrEmpty]
3737
public string ResourceName { get; set; }
3838

39+
[Parameter(Position = 2, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.Location, ValueFromPipelineByPropertyName = true)]
40+
[ValidateNotNullOrEmpty]
41+
public string Location { get; set; }
3942

4043
public override void ExecuteCmdlet()
4144
{
4245
base.ExecuteCmdlet();
4346

4447
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", ResourceGroupName, ResourceName));
4548

46-
InitializeAzureBackupCmdlet(ResourceGroupName, ResourceName);
49+
InitializeAzureBackupCmdlet(ResourceGroupName, ResourceName, Location);
4750
}
4851
}
4952
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/GetAzureBackupContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public override void ExecuteCmdlet()
7171

7272
WriteObject(containerInfos.ConvertAll(containerInfo =>
7373
{
74-
return new AzureBackupContainer(containerInfo);
74+
return new AzureBackupContainer(containerInfo, ResourceGroupName, ResourceName, Location);
7575
}));
7676
});
7777
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/GetAzureBackupProtectionPolicy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
2727
[Cmdlet(VerbsCommon.Get, "AzureBackupProtectionPolicy"), OutputType(typeof(AzureBackupProtectionPolicy), typeof(List<AzureBackupProtectionPolicy>))]
2828
public class GetAzureBackupProtectionPolicy : AzureBackupVaultCmdletBase
2929
{
30-
[Parameter(Position = 2, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.PolicyName)]
30+
[Parameter(Position = 3, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.PolicyName)]
3131
[ValidateNotNullOrEmpty]
3232
public string Name { get; set; }
3333

@@ -60,7 +60,7 @@ public override void ExecuteCmdlet()
6060

6161
public void WriteAzureBackupProtectionPolicy(ProtectionPolicyInfo sourcePolicy)
6262
{
63-
this.WriteObject(new AzureBackupProtectionPolicy(ResourceGroupName, ResourceName, sourcePolicy));
63+
this.WriteObject(new AzureBackupProtectionPolicy(ResourceGroupName, ResourceName, Location, sourcePolicy));
6464
}
6565

6666
public void WriteAzureBackupProtectionPolicy(IEnumerable<ProtectionPolicyInfo> sourcePolicyList)
@@ -69,7 +69,7 @@ public void WriteAzureBackupProtectionPolicy(IEnumerable<ProtectionPolicyInfo> s
6969

7070
foreach (var sourcePolicy in sourcePolicyList)
7171
{
72-
targetList.Add(new AzureBackupProtectionPolicy(ResourceGroupName, ResourceName, sourcePolicy));
72+
targetList.Add(new AzureBackupProtectionPolicy(ResourceGroupName, ResourceName, Location, sourcePolicy));
7373
}
7474

7575
this.WriteObject(targetList, true);

src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ public class AzureBackupVaultContextObject
2727
/// </summary>
2828
public string ResourceName { get; set; }
2929

30+
/// <summary>
31+
/// ResourceName of the azurebackup object
32+
/// </summary>
33+
public string Location { get; set; }
34+
3035
public AzureBackupVaultContextObject()
3136
{
3237
}
33-
34-
public AzureBackupVaultContextObject(string resourceGroupName, string resourceName)
38+
39+
public AzureBackupVaultContextObject(string resourceGroupName, string resourceName, string locationName)
3540
{
3641
ResourceGroupName = resourceGroupName;
3742
ResourceName = resourceName;
43+
Location = locationName;
3844
}
3945
}
4046

@@ -60,20 +66,20 @@ public AzureBackupContainerContextObject()
6066
}
6167

6268
public AzureBackupContainerContextObject(AzureBackupContainerContextObject azureBackupContainerContextObject)
63-
: base(azureBackupContainerContextObject.ResourceGroupName, azureBackupContainerContextObject.ResourceName)
69+
: base(azureBackupContainerContextObject.ResourceGroupName, azureBackupContainerContextObject.ResourceName, azureBackupContainerContextObject.Location)
6470
{
6571
ContainerType = azureBackupContainerContextObject.ContainerType;
6672
ContainerUniqueName = azureBackupContainerContextObject.ContainerUniqueName;
6773
}
6874
public AzureBackupContainerContextObject(AzureBackupContainer azureBackupContainer)
69-
: base(azureBackupContainer.ResourceGroupName, azureBackupContainer.ResourceName)
75+
: base(azureBackupContainer.ResourceGroupName, azureBackupContainer.ResourceName, azureBackupContainer.Location)
7076
{
7177
ContainerType = azureBackupContainer.ContainerType;
7278
ContainerUniqueName = azureBackupContainer.ContainerUniqueName;
7379
}
7480

75-
public AzureBackupContainerContextObject(ContainerInfo containerInfo)
76-
: base(containerInfo.ParentContainerName, containerInfo.FriendlyName)
81+
public AzureBackupContainerContextObject(ContainerInfo containerInfo, string rgName, string rName, string location)
82+
: base(rgName, rName, location)
7783
{
7884
ContainerType = containerInfo.ContainerType;
7985
ContainerUniqueName = containerInfo.Name;

src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupContainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public class AzureBackupContainer : AzureBackupContainerContextObject
3838

3939
public AzureBackupContainer() : base() { }
4040

41-
public AzureBackupContainer(ContainerInfo containerInfo)
42-
: base(containerInfo)
41+
public AzureBackupContainer(ContainerInfo containerInfo, string rgName, string rName, string location)
42+
: base(containerInfo, rgName, rName, location)
4343
{
4444
HealthStatus = containerInfo.HealthStatus;
4545
RegistrationStatus = containerInfo.RegistrationStatus;

src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/ProtectionPolicy.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public AzureBackupProtectionPolicy()
4848
{
4949
}
5050

51-
public AzureBackupProtectionPolicy(string resourceGroupName, string resourceName, ProtectionPolicyInfo sourcePolicy) : base(resourceGroupName, resourceName)
51+
public AzureBackupProtectionPolicy(string resourceGroupName, string resourceName, string location, ProtectionPolicyInfo sourcePolicy)
52+
: base(resourceGroupName, resourceName, location)
5253
{
5354
InstanceId = sourcePolicy.InstanceId;
5455
Name = sourcePolicy.Name;

0 commit comments

Comments
 (0)