Skip to content
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

[NetAppFiles] Add missing parameter SnapshotName #25837

Merged
merged 5 commits into from
Aug 20, 2024
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
25 changes: 16 additions & 9 deletions src/NetAppFiles/NetAppFiles/Backups/NewNetAppFilesBackup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ public class NewAzureRmNetAppFilesBackup : AzureNetAppFilesCmdletBase
public string Name { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "ResourceId used to identify the Volume")]
Mandatory = true,
HelpMessage = "ResourceId used to identify the Volume")]
public string VolumeResourceId { get; set; }

[Parameter(
Mandatory = true,
Mandatory = false,
HelpMessage = "Label for backup")]
[ValidateNotNullOrEmpty]
public string Label { get; set; }
Expand All @@ -129,6 +129,12 @@ public class NewAzureRmNetAppFilesBackup : AzureNetAppFilesCmdletBase
[ValidateNotNullOrEmpty]
public SwitchParameter UseExistingSnapshot { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "The name of the snapshot, use with UseExistingSnapshot")]
[ValidateNotNullOrEmpty]
public string SnapshotName { get; set; }

[CmdletParameterBreakingChangeWithVersion("VolumeObject", "12", "0.16", ChangeDescription = ChangeDesc)]
[Parameter(
ParameterSetName = ParentObjectParameterSet,
Expand All @@ -154,26 +160,27 @@ public override void ExecuteCmdlet()
Location = BackupVaultObject.Location;
var NameParts = BackupVaultObject.Name.Split('/');
AccountName = NameParts[0];
BackupVaultName = NameParts[1];
BackupVaultName = NameParts[1];
}
if (!ResourceIdentifier.TryParse(VolumeResourceId, out _))
{
throw new Exception($"VolumeResourceId is an invalid resource Id");
}

var backupBody = new Management.NetApp.Models.Backup()
{
{
Label = Label,
VolumeResourceId = VolumeResourceId,
UseExistingSnapshot = UseExistingSnapshot,
VolumeResourceId = VolumeResourceId
SnapshotName = SnapshotName
};

if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.CreateResourceMessage, ResourceGroupName)))
{
try
{
var anfBackupPolicy = AzureNetAppFilesManagementClient.Backups.Create(ResourceGroupName, AccountName, backupVaultName:BackupVaultName, backupName: Name, body: backupBody);
WriteObject(anfBackupPolicy.ConvertToPs());
var anfBackup = AzureNetAppFilesManagementClient.Backups.Create(ResourceGroupName, AccountName, backupVaultName: BackupVaultName, backupName: Name, body: backupBody);
WriteObject(anfBackup.ConvertToPs());
}
catch (ErrorResponseException ex)
{
Expand All @@ -182,4 +189,4 @@ public override void ExecuteCmdlet()
}
}
}
}
}
2 changes: 2 additions & 0 deletions src/NetAppFiles/NetAppFiles/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
-->
## Upcoming Release
* Fixed some minor issues
* Added `SnapshotName` to `New-AzNetAppFilesBackup`
* Fixed `New-AzNetAppFilesBackup`, `Label` is not a requred parameter

## Version 0.17.0
* Updated to api-version 2024-03-01
Expand Down
5 changes: 3 additions & 2 deletions src/NetAppFiles/NetAppFiles/Helpers/BackupExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static PSNetAppFilesBackup ConvertToPs(this Management.NetApp.Models.Back
{
var psBackup = new PSNetAppFilesBackup
{
ResourceGroupName = new ResourceIdentifier(backup.Id).ResourceGroupName,
ResourceGroupName = new ResourceIdentifier(backup.Id).ResourceGroupName,
Id = backup.Id,
Name = backup.Name,
BackupId = backup.BackupId,
Expand All @@ -36,6 +36,7 @@ public static PSNetAppFilesBackup ConvertToPs(this Management.NetApp.Models.Back
Size = backup.Size,
VolumeResourceId = backup.VolumeResourceId,
UseExistingSnapshot = backup.UseExistingSnapshot,
SnapshotName = backup.SnapshotName,
CreationDate = backup.CreationDate
};
return psBackup;
Expand Down Expand Up @@ -76,4 +77,4 @@ public static PSNetAppFilesVolumeRestoreStatus ConvertToPs(this Management.NetAp
return psRestoreStatus;
}
}
}
}
9 changes: 8 additions & 1 deletion src/NetAppFiles/NetAppFiles/Models/PSNetAppFilesBackup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public class PSNetAppFilesBackup
/// false for scheduled backups and true/false for manual backups
/// </remarks>
public bool? UseExistingSnapshot { get; set; }


/// <summary>
/// Gets or sets SnapshotName
/// </summary>
/// <remarks>
/// The name of the snapshot
/// </remarks>
public string SnapshotName { get; set; }
}
}
45 changes: 38 additions & 7 deletions src/NetAppFiles/NetAppFiles/help/New-AzNetAppFilesBackup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ Creates a new Azure NetApp Files (ANF) backup.
```
New-AzNetAppFilesBackup -ResourceGroupName <String> [-Location <String>] -AccountName <String>
[-PoolName <String>] [-VolumeName <String>] -BackupVaultName <String> -Name <String>
-VolumeResourceId <String> -Label <String> [-UseExistingSnapshot] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
-VolumeResourceId <String> [-Label <String>] [-UseExistingSnapshot] [-SnapshotName <String>]
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### ByParentObjectParameterSet
```
New-AzNetAppFilesBackup -Name <String> -VolumeResourceId <String> -Label <String> [-UseExistingSnapshot]
[-VolumeObject <PSNetAppFilesVolume>] -BackupVaultObject <PSNetAppFilesBackupVault>
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
New-AzNetAppFilesBackup -Name <String> -VolumeResourceId <String> [-Label <String>] [-UseExistingSnapshot]
[-SnapshotName <String>] [-VolumeObject <PSNetAppFilesVolume>] -BackupVaultObject <PSNetAppFilesBackupVault>
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

Expand Down Expand Up @@ -110,7 +111,7 @@ Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Expand Down Expand Up @@ -162,6 +163,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ProgressAction
{{ Fill ProgressAction Description }}

```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ResourceGroupName
The resource group of the ANF account

Expand All @@ -177,6 +193,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -SnapshotName
The name of the snapshot, use with UseExistingSnapshot

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -UseExistingSnapshot
Manual backup an already existing snapshot. This will always be false for scheduled backups and true/false for manual backups

Expand Down Expand Up @@ -295,4 +326,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
[Get-AzNetAppFilesVolume](./Get-AzNetAppFilesVolume.md)
[New-AzNetAppFilesVolume](./New-AzNetAppFilesVolume.md)
[Update-AzNetAppFilesVolume](./Update-AzNetAppFilesVolume.md)
[Remove-AzNetAppFilesVolume](./Remove-AzNetAppFilesVolume.md)
[Remove-AzNetAppFilesVolume](./Remove-AzNetAppFilesVolume.md)