Skip to content

Commit bb3da11

Browse files
add powershell module and test for alert repair SDK
fix spacing add hasvalidremediationaction check for repair tests add changelog and update assembly version reference fix typo update references Update assembly version and added negative unit tests for repair alert fix spacing
1 parent 95f7837 commit bb3da11

File tree

11 files changed

+1718
-27
lines changed

11 files changed

+1718
-27
lines changed

src/StackAdmin/Azs.InfrastructureInsights.Admin/Module/Azs.InfrastructureInsights.Admin.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
<Prefer32Bit>false</Prefer32Bit>
4141
</PropertyGroup>
4242
<ItemGroup>
43-
<Reference Include="Microsoft.AzureStack.Management.InfrastructureInsights.Admin, Version=0.2.0-preview">
44-
<HintPath>..\..\..\packages\Microsoft.AzureStack.Management.InfrastructureInsights.Admin.0.2.0-preview\lib\net452\Microsoft.AzureStack.Management.InfrastructureInsights.Admin.dll</HintPath>
43+
<Reference Include="Microsoft.AzureStack.Management.InfrastructureInsights.Admin, Version=0.3.0-preview">
44+
<HintPath>..\..\..\packages\Microsoft.AzureStack.Management.InfrastructureInsights.Admin.0.3.0-preview\lib\net452\Microsoft.AzureStack.Management.InfrastructureInsights.Admin.dll</HintPath>
4545
</Reference>
4646
</ItemGroup>
4747
<ItemGroup>

src/StackAdmin/Azs.InfrastructureInsights.Admin/Module/Azs.InfrastructureInsights.Admin/Azs.Infrastructureinsights.Admin.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Licensed under the MIT License. See License.txt in the project root for license
1717
RootModule = 'Azs.InfrastructureInsights.Admin.psm1'
1818

1919
# Version number of this module.
20-
ModuleVersion = '0.2.0'
20+
ModuleVersion = '0.3.0'
2121

2222
# Supported PSEditions
2323
# CompatiblePSEditions = @()

src/StackAdmin/Azs.InfrastructureInsights.Admin/Module/Azs.InfrastructureInsights.Admin/ChangeLog.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
## Version 0.3.0
22+
* New admin cmdlet added
23+
* Repair-AzsAlert
2124

2225
## Version 0.2.0
2326
* Module dependencies updated
24-
* AzureRM.Profile
25-
* AzureRM.Resources
27+
* AzureRM.Profile
28+
* AzureRM.Resources
2629
* Support handling names of nested resources
27-
* Get-AzsAlert
28-
* Close-AzsAlert
29-
* Get-AzsRegistrationHealth
30-
* Get-AzsRPHealth
30+
* Get-AzsAlert
31+
* Close-AzsAlert
32+
* Get-AzsRegistrationHealth
33+
* Get-AzsRPHealth
3134
* Deprecations
32-
* Get-AzsRegistrationHealth, the parameter ResourceHealthId is now an alias for Name
33-
* Get-AzsRegistrationHealth, the parameter ServiceRegistrationId is now an alias for ServiceRegistrationName
34-
* Get-AzsRPHealth, the parameter ServiceHealth is now an alias for Name
35+
* Get-AzsRegistrationHealth, the parameter ResourceHealthId is now an alias for Name
36+
* Get-AzsRegistrationHealth, the parameter ServiceRegistrationId is now an alias for ServiceRegistrationName
37+
* Get-AzsRPHealth, the parameter ServiceHealth is now an alias for Name
3538
* Bug fixes
36-
* Handle ErrrorAction correctly now
39+
* Handle ErrrorAction correctly now
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<#
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the MIT License. See License.txt in the project root for license information.
4+
#>
5+
6+
<#
7+
.SYNOPSIS
8+
Repairs the given alert.
9+
10+
.DESCRIPTION
11+
Repairs the given alert.
12+
13+
.PARAMETER Name
14+
The alert identifier.
15+
16+
.PARAMETER Location
17+
Name of the location.
18+
19+
.PARAMETER ResourceGroupName
20+
Resource group name which the resource resides.
21+
22+
.PARAMETER InputObject
23+
An alert returned from Get-AzsAlert.
24+
25+
.PARAMETER Force
26+
Don't ask for confirmation.
27+
28+
.EXAMPLE
29+
30+
PS C:\> Repair-AzsAlert -Name f2147f3d-42ac-4316-8cbc-f0f9c18888b0
31+
32+
Repairs an alert by Name.
33+
34+
.EXAMPLE
35+
36+
PS C:\> Get-AzsAlert -Name f2147f3d-42ac-4316-8cbc-f0f9c18888b0 | Repair-AzsAlert
37+
38+
Repairs an alert through piping.
39+
40+
#>
41+
function Repair-AzsAlert {
42+
[CmdletBinding(DefaultParameterSetName = 'Repair', SupportsShouldProcess = $true)]
43+
param(
44+
[Parameter(Mandatory = $true, ParameterSetName = 'Repair')]
45+
[ValidateNotNullOrEmpty()]
46+
[System.String]
47+
$Name,
48+
49+
[Parameter(Mandatory = $false, ParameterSetName = 'Repair')]
50+
[System.String]
51+
$Location,
52+
53+
[Parameter(Mandatory = $false, ParameterSetName = 'Repair')]
54+
[ValidateLength(1, 90)]
55+
[System.String]
56+
$ResourceGroupName,
57+
58+
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = 'InputObject')]
59+
[ValidateNotNullOrEmpty()]
60+
[Microsoft.AzureStack.Management.InfrastructureInsights.Admin.Models.Alert]
61+
$InputObject,
62+
63+
[Parameter(Mandatory = $false)]
64+
[switch]
65+
$Force
66+
)
67+
68+
Begin {
69+
Initialize-PSSwaggerDependencies -Azure
70+
$tracerObject = $null
71+
if (('continue' -eq $DebugPreference) -or ('inquire' -eq $DebugPreference)) {
72+
$oldDebugPreference = $global:DebugPreference
73+
$global:DebugPreference = "continue"
74+
$tracerObject = New-PSSwaggerClientTracing
75+
Register-PSSwaggerClientTracing -TracerObject $tracerObject
76+
}
77+
}
78+
79+
Process {
80+
81+
if ('InputObject' -eq $PsCmdlet.ParameterSetName) {
82+
$GetArmResourceIdParameterValue_params = @{
83+
IdTemplate = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.InfrastructureInsights.Admin/regionHealths/{region}/alerts/{alertName}'
84+
}
85+
86+
$GetArmResourceIdParameterValue_params['Id'] = $InputObject.Id
87+
$ArmResourceIdParameterValues = Get-ArmResourceIdParameterValue @GetArmResourceIdParameterValue_params
88+
89+
$ResourceGroupName = $ArmResourceIdParameterValues['resourceGroupName']
90+
$Location = $ArmResourceIdParameterValues['region']
91+
$Name = $ArmResourceIdParameterValues['alertName']
92+
}
93+
94+
if ($PSCmdlet.ShouldProcess("$Name" , "Repair Alert")) {
95+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Repair Alert?", "Performing operation repair on alert $Name")) {
96+
97+
$NewServiceClient_params = @{
98+
FullClientTypeName = 'Microsoft.AzureStack.Management.InfrastructureInsights.Admin.InfrastructureInsightsAdminClient'
99+
}
100+
101+
$GlobalParameterHashtable = @{}
102+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
103+
104+
$GlobalParameterHashtable['SubscriptionId'] = $null
105+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
106+
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
107+
}
108+
109+
$InfrastructureInsightsAdminClient = New-ServiceClient @NewServiceClient_params
110+
111+
if ([System.String]::IsNullOrEmpty($Location)) {
112+
$Location = (Get-AzureRMLocation).Location
113+
}
114+
115+
if ([System.String]::IsNullOrEmpty($ResourceGroupName)) {
116+
$ResourceGroupName = "System.$Location"
117+
}
118+
119+
if ('Repair' -eq $PsCmdlet.ParameterSetName -or 'InputObject' -eq $PsCmdlet.ParameterSetName) {
120+
Write-Verbose -Message 'Performing operation RepairWithHttpMessagesAsync on $InfrastructureInsightsAdminClient.'
121+
$TaskResult = $InfrastructureInsightsAdminClient.Alerts.RepairWithHttpMessagesAsync($ResourceGroupName, $Location, $Name)
122+
} else {
123+
Write-Verbose -Message 'Failed to map parameter set to operation method.'
124+
throw 'Module failed to find operation to execute.'
125+
}
126+
127+
if ($TaskResult) {
128+
$GetTaskResult_params = @{
129+
TaskResult = $TaskResult
130+
}
131+
132+
Get-TaskResult @GetTaskResult_params
133+
}
134+
}
135+
}
136+
}
137+
138+
End {
139+
if ($tracerObject) {
140+
$global:DebugPreference = $oldDebugPreference
141+
Unregister-PSSwaggerClientTracing -TracerObject $tracerObject
142+
}
143+
}
144+
}
145+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.AzureStack.Management.InfrastructureInsights.Admin" version="0.2.0-preview" targetFramework="net452" />
3+
<package id="Microsoft.AzureStack.Management.InfrastructureInsights.Admin" version="0.3.0-preview" targetFramework="net452" />
44
</packages>

src/StackAdmin/Azs.InfrastructureInsights.Admin/Tests/Azs.InfrastructureInsights.Admin.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
<Prefer32Bit>false</Prefer32Bit>
4141
</PropertyGroup>
4242
<ItemGroup>
43-
<Reference Include="Microsoft.AzureStack.Management.InfrastructureInsights.Admin, Version=0.2.0-preview">
44-
<HintPath>..\..\..\packages\Microsoft.AzureStack.Management.InfrastructureInsights.Admin.0.2.0-preview\lib\net452\Microsoft.AzureStack.Management.InfrastructureInsights.Admin.dll</HintPath>
43+
<Reference Include="Microsoft.AzureStack.Management.InfrastructureInsights.Admin, Version=0.3.0-preview">
44+
<HintPath>..\..\..\packages\Microsoft.AzureStack.Management.InfrastructureInsights.Admin.0.3.0-preview\lib\net452\Microsoft.AzureStack.Management.InfrastructureInsights.Admin.dll</HintPath>
4545
</Reference>
4646
</ItemGroup>
4747
<ItemGroup>

src/StackAdmin/Azs.InfrastructureInsights.Admin/Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("2.0.0.0")]
36+
[assembly: AssemblyFileVersion("2.0.0.0")]

0 commit comments

Comments
 (0)