Skip to content

Commit 2826fad

Browse files
author
REDMOND\xizha
committed
added support for retentionInDays parameter, updated the test records
1 parent 7011893 commit 2826fad

File tree

11 files changed

+588
-474
lines changed

11 files changed

+588
-474
lines changed

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/ScenarioTests/WorkspaceTests.ps1

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ function Test-WorkspaceCreateUpdateDelete
3030
Assert-AreEqual $wsname $workspace.Name
3131
Assert-AreEqual $wslocation $workspace.Location
3232
Assert-AreEqual "STANDARD" $workspace.Sku
33+
# if no value for RetentionInDays is specified, use the default value for the sku. For standard, the default is 30.
34+
Assert-AreEqual 30 $workspace.RetentionInDays
3335
Assert-NotNull $workspace.ResourceId
3436
Assert-AreEqual 1 $workspace.Tags.Count
3537
Assert-NotNull $workspace.CustomerId
@@ -40,15 +42,19 @@ function Test-WorkspaceCreateUpdateDelete
4042
Assert-AreEqual $wsname $workspace.Name
4143
Assert-AreEqual $wslocation $workspace.Location
4244
Assert-AreEqual "STANDARD" $workspace.Sku
45+
Assert-AreEqual 30 $workspace.RetentionInDays
4346
Assert-NotNull $workspace.ResourceId
4447
Assert-AreEqual 1 $workspace.Tags.Count
4548
Assert-NotNull $workspace.CustomerId
4649
Assert-NotNull $workspace.PortalUrl
4750

4851
# Create a second workspace for list testing
4952
$wstwoname = Get-ResourceName
50-
$workspacetwo = New-AzureRmOperationalInsightsWorkspace -ResourceGroupName $rgname -Name $wstwoname -Location $wslocation -Sku "STANDARD" -Force
51-
53+
$workspacetwo = New-AzureRmOperationalInsightsWorkspace -ResourceGroupName $rgname -Name $wstwoname -Location $wslocation -Sku "PerNode" -RetentionInDays 60 -Force
54+
55+
$workspacetwo = Get-AzureRmOperationalInsightsWorkspace -ResourceGroupName $rgname -Name $wstwoname
56+
Assert-AreEqual 60 $workspacetwo.RetentionInDays
57+
5258
# List the workspaces in the subscription
5359
$workspaces = Get-AzureRmOperationalInsightsWorkspace
5460
Assert-AreEqual 1 ($workspaces | Where {$_.Name -eq $wsname}).Count
@@ -73,11 +79,12 @@ function Test-WorkspaceCreateUpdateDelete
7379
$workspace = $workspace | New-AzureRmOperationalInsightsWorkspace -Tags @{"foo" = "bar"} -Force
7480
Assert-AreEqual 1 $workspace.Tags.Count
7581

76-
# Clear the tags and update the sku via piping
77-
$workspace | Set-AzureRmOperationalInsightsWorkspace -Tags @{} -Sku standard
82+
# Clear the tags and update the sku, RetentionInDays via piping
83+
$workspace | Set-AzureRmOperationalInsightsWorkspace -Tags @{} -Sku standalone -RetentionInDays 123
7884
$workspace = Get-AzureRmOperationalInsightsWorkspace -ResourceGroupName $rgname -Name $wsname
7985
Assert-AreEqual 0 $workspace.Tags.Count
80-
Assert-AreEqual standard $workspace.Sku
86+
Assert-AreEqual standalone $workspace.Sku
87+
Assert-AreEqual 123 $workspace.RetentionInDays
8188

8289
# Delete the original workspace via piping
8390
$workspace | Remove-AzureRmOperationalInsightsWorkspace -Force

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/SessionRecords/Microsoft.Azure.Commands.OperationalInsights.Test.SearchTests/TestSearchGetSchema.json

Lines changed: 67 additions & 58 deletions
Large diffs are not rendered by default.

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/SessionRecords/Microsoft.Azure.Commands.OperationalInsights.Test.WorkspaceTests/TestWorkspaceActions.json

Lines changed: 110 additions & 110 deletions
Large diffs are not rendered by default.

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/SessionRecords/Microsoft.Azure.Commands.OperationalInsights.Test.WorkspaceTests/TestWorkspaceCreateUpdateDelete.json

Lines changed: 262 additions & 191 deletions
Large diffs are not rendered by default.

src/ResourceManager/OperationalInsights/Commands.OperationalInsights.Test/SessionRecords/Microsoft.Azure.Commands.OperationalInsights.Test.WorkspaceTests/TestWorkspaceEnableDisableListIntelligencePacks.json

Lines changed: 104 additions & 104 deletions
Large diffs are not rendered by default.

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Client/OperationalInsightsClient.Workspaces.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ public virtual Workspace CreateOrUpdateWorkspace(
122122
string location,
123123
string sku,
124124
Guid? customerId,
125-
IDictionary<string, string> tags)
125+
IDictionary<string, string> tags,
126+
int? retentionInDays)
126127
{
127128
Workspace properties = new Workspace()
128129
{
@@ -140,6 +141,11 @@ public virtual Workspace CreateOrUpdateWorkspace(
140141
properties.CustomerId = customerId.Value.ToString();
141142
}
142143

144+
if (retentionInDays.HasValue)
145+
{
146+
properties.RetentionInDays = retentionInDays.Value;
147+
}
148+
143149
var response = OperationalInsightsManagementClient.Workspaces.CreateOrUpdate(
144150
resourceGroupName,
145151
workspaceName,
@@ -160,7 +166,8 @@ public virtual PSWorkspace UpdatePSWorkspace(UpdatePSWorkspaceParameters paramet
160166
workspace.Location,
161167
string.IsNullOrWhiteSpace(parameters.Sku) ? workspace.Sku : parameters.Sku,
162168
workspace.CustomerId,
163-
parameters.Tags == null ? workspace.Tags : ToDictionary(parameters.Tags));
169+
parameters.Tags == null ? workspace.Tags : ToDictionary(parameters.Tags),
170+
parameters.RetentionInDays);
164171

165172
return new PSWorkspace(updatedWorkspace, parameters.ResourceGroupName);
166173
}
@@ -184,7 +191,8 @@ public virtual PSWorkspace CreatePSWorkspace(CreatePSWorkspaceParameters paramet
184191
parameters.Location,
185192
parameters.Sku,
186193
parameters.CustomerId,
187-
tags),
194+
tags,
195+
parameters.RetentionInDays),
188196
parameters.ResourceGroupName);
189197
if (!string.Equals(workspace.ProvisioningState, OperationStatus.Succeeded.ToString(), StringComparison.OrdinalIgnoreCase))
190198
{

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Models/CreatePSWorkspaceParameters.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class CreatePSWorkspaceParameters : OperationalInsightsParametersBase
2929

3030
public Hashtable Tags { get; set; }
3131

32+
public int? RetentionInDays { get; set; }
33+
3234
public Action<bool, string, string, string, Action, Func<bool>> ConfirmAction { get; set; }
3335
}
3436
}

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Models/PSWorkspace.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public PSWorkspace(Workspace workspace, string resourceGroupName)
4040
if (workspace!= null)
4141
{
4242
this.Sku = workspace.Sku != null ? workspace.Sku.Name : null;
43+
this.retentionInDays = workspace.RetentionInDays;
4344
this.CustomerId = new Guid(workspace.CustomerId);
4445
this.PortalUrl = workspace.PortalUrl;
4546
this.ProvisioningState = workspace.ProvisioningState;
@@ -58,6 +59,8 @@ public PSWorkspace(Workspace workspace, string resourceGroupName)
5859

5960
public string Sku { get; set; }
6061

62+
public int? retentionInDays { get; set; }
63+
6164
public Guid? CustomerId { get; set; }
6265

6366
public string PortalUrl { get; set; }

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Models/UpdatePSWorkspaceParameters.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ public class UpdatePSWorkspaceParameters : OperationalInsightsParametersBase
2121
public string Sku { get; set; }
2222

2323
public Hashtable Tags { get; set; }
24+
25+
public int? RetentionInDays { get; set; }
2426
}
2527
}

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Workspaces/NewAzureOperationalInsightsWorkspaceCommand.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class NewAzureOperationalInsightsWorkspaceCommand : OperationalInsightsBa
3939

4040
[Parameter(Position = 3, Mandatory = false, ValueFromPipelineByPropertyName = true,
4141
HelpMessage = "The service tier of the workspace.")]
42-
[ValidateSet("free", "standard", "premium", IgnoreCase = true)]
42+
[ValidateSet("free", "standard", "premium", "pernode","standalone", IgnoreCase = true)]
4343
public string Sku { get; set; }
4444

4545
[Parameter(Position = 4, Mandatory = false, ValueFromPipelineByPropertyName = true,
@@ -50,6 +50,11 @@ public class NewAzureOperationalInsightsWorkspaceCommand : OperationalInsightsBa
5050
HelpMessage = "The resource tags for the workspace.")]
5151
public Hashtable Tags { get; set; }
5252

53+
[Parameter(Position = 6, Mandatory = false, ValueFromPipelineByPropertyName = true,
54+
HelpMessage = "The workspace data retention in days. 730 days is the maximum allowed for all other Skus.")]
55+
[ValidateNotNullOrEmpty]
56+
public int? RetentionInDays { get; set; }
57+
5358
[Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")]
5459
public SwitchParameter Force { get; set; }
5560

@@ -63,6 +68,7 @@ public override void ExecuteCmdlet()
6368
Sku = Sku,
6469
CustomerId = CustomerId,
6570
Tags = Tags,
71+
RetentionInDays = RetentionInDays,
6672
Force = Force.IsPresent,
6773
ConfirmAction = ConfirmAction
6874
};

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Workspaces/SetAzureOperationalInsightsWorkspaceCommand.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ public class SetAzureOperationalInsightsWorkspaceCommand : OperationalInsightsBa
3838

3939
[Parameter(Position = 3, Mandatory = false, ValueFromPipelineByPropertyName = true,
4040
HelpMessage = "The service tier of the workspace.")]
41-
[ValidateSet("free", "standard", "premium", IgnoreCase = true)]
41+
[ValidateSet("free", "standard", "premium", "pernode", "standalone", IgnoreCase = true)]
4242
public string Sku { get; set; }
4343

4444
[Parameter(Position = 4, Mandatory = false, ValueFromPipelineByPropertyName = true,
4545
HelpMessage = "The resource tags for the workspace.")]
4646
public Hashtable Tags { get; set; }
4747

48+
[Parameter(Position = 5, Mandatory = false, ValueFromPipelineByPropertyName = true,
49+
HelpMessage = "The workspace data retention in days. 730 days is the maximum allowed for all other Skus.")]
50+
[ValidateNotNullOrEmpty]
51+
public int? RetentionInDays { get; set; }
52+
4853
public override void ExecuteCmdlet()
4954
{
5055
if (ParameterSetName == ByObject)
@@ -58,7 +63,8 @@ public override void ExecuteCmdlet()
5863
ResourceGroupName = ResourceGroupName,
5964
WorkspaceName = Name,
6065
Sku = Sku,
61-
Tags = Tags
66+
Tags = Tags,
67+
RetentionInDays = RetentionInDays
6268
};
6369

6470
WriteObject(OperationalInsightsClient.UpdatePSWorkspace(parameters));

0 commit comments

Comments
 (0)