Skip to content

Commit 3292520

Browse files
committed
Introducing announced change in output type for AddAlertRule and AddAutoscaleSetting cmdlets.
1 parent bc616cf commit 3292520

File tree

5 files changed

+16
-25
lines changed

5 files changed

+16
-25
lines changed

src/ResourceManager/Insights/Commands.Insights/Alerts/AddAzureRmAlertRuleCommandBase.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System.Net;
16-
using System.Threading.Tasks;
17-
using Microsoft.Azure.Management.Monitor.Management;
16+
using Microsoft.Azure.Commands.Insights.OutputClasses;
1817
using Microsoft.Azure.Management.Monitor.Management.Models;
1918
using System.Collections.Generic;
2019
using System.Management.Automation;
@@ -77,21 +76,16 @@ public abstract class AddAzureRmAlertRuleCommandBase : ManagementCmdletBase
7776
/// </summary>
7877
protected override void ProcessRecordInternal()
7978
{
80-
WriteWarning("The output of this cmdlet will change in the next release to return a single object, not a list, that includes the updated or newly created object.");
8179
AlertRuleResource parameters = this.CreateSdkCallParameters();
8280

8381
// Part of the result of this operation is operation (result.Body ==> a AutoscaleSettingResource) is being discarded for backwards compatibility
8482
var result = this.MonitorManagementClient.AlertRules.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName: this.ResourceGroup, parameters: parameters, ruleName: parameters.AlertRuleResourceName).Result;
8583

86-
// Keep this response for backwards compatibility.
87-
// Note: Create operations return the newly created object in the new specification, i.e. need to use result.Body
88-
var response = new List<AzureOperationResponse>
84+
var response = new PSAddAlertRuleOperationResponse
8985
{
90-
new AzureOperationResponse()
91-
{
92-
RequestId = result.RequestId,
93-
StatusCode = HttpStatusCode.OK
94-
}
86+
RequestId = result.RequestId,
87+
StatusCode = result.Response != null ? result.Response.StatusCode : HttpStatusCode.OK,
88+
AlertRule = result.Body
9589
};
9690

9791
WriteObject(response);

src/ResourceManager/Insights/Commands.Insights/Alerts/AddAzureRmLogAlertRuleCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Management.Automation;
19+
using Microsoft.Azure.Commands.Insights.OutputClasses;
1920

2021
namespace Microsoft.Azure.Commands.Insights.Alerts
2122
{
2223
/// <summary>
2324
/// Add an Alert rule
2425
/// </summary>
25-
[Cmdlet(VerbsCommon.Add, "AzureRmLogAlertRule"), OutputType(typeof(List<PSObject>))]
26+
[Cmdlet(VerbsCommon.Add, "AzureRmLogAlertRule"), OutputType(typeof(PSAddAlertRuleOperationResponse))]
2627
public class AddAzureRmLogAlertRuleCommand : AddAzureRmAlertRuleCommandBase
2728
{
2829
/// <summary>

src/ResourceManager/Insights/Commands.Insights/Alerts/AddAzureRmMetricAlertRuleCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Insights.OutputClasses;
1516
using Microsoft.Azure.Management.Monitor.Management.Models;
1617
using System;
1718
using System.Collections.Generic;
@@ -22,7 +23,7 @@ namespace Microsoft.Azure.Commands.Insights.Alerts
2223
/// <summary>
2324
/// Add an Alert rule
2425
/// </summary>
25-
[Cmdlet(VerbsCommon.Add, "AzureRmMetricAlertRule"), OutputType(typeof(List<PSObject>))]
26+
[Cmdlet(VerbsCommon.Add, "AzureRmMetricAlertRule"), OutputType(typeof(PSAddAlertRuleOperationResponse))]
2627
public class AddAzureRmMetricAlertRuleCommand : AddAzureRmAlertRuleCommandBase
2728
{
2829
/// <summary>

src/ResourceManager/Insights/Commands.Insights/Alerts/AddAzureRmWebtestAlertRuleCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Commands.Insights.OutputClasses;
1516
using Microsoft.Azure.Management.Monitor.Management.Models;
1617
using System;
1718
using System.Collections.Generic;
@@ -22,7 +23,7 @@ namespace Microsoft.Azure.Commands.Insights.Alerts
2223
/// <summary>
2324
/// Add an Alert rule
2425
/// </summary>
25-
[Cmdlet(VerbsCommon.Add, "AzureRmWebtestAlertRule"), OutputType(typeof(List<PSObject>))]
26+
[Cmdlet(VerbsCommon.Add, "AzureRmWebtestAlertRule"), OutputType(typeof(PSAddAlertRuleOperationResponse))]
2627
public class AddAzureRmWebtestAlertRuleCommand : AddAzureRmAlertRuleCommandBase
2728
{
2829
/// <summary>

src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAzureRmAutoscaleSettingCommand.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace Microsoft.Azure.Commands.Insights.Autoscale
2828
/// <summary>
2929
/// Create or update an Autoscale setting
3030
/// </summary>
31-
[Cmdlet(VerbsCommon.Add, "AzureRmAutoscaleSetting"), OutputType(typeof(AzureOperationResponse))]
31+
[Cmdlet(VerbsCommon.Add, "AzureRmAutoscaleSetting"), OutputType(typeof(PSAddAutoscaleSettingOperationResponse))]
3232
public class AddAzureRmAutoscaleSettingCommand : ManagementCmdletBase
3333
{
3434
internal const string AddAzureRmAutoscaleSettingCreateParamGroup = "Parameters for Add-AzureRmAutoscaleSetting cmdlet in the create semantics";
@@ -102,21 +102,15 @@ public class AddAzureRmAutoscaleSettingCommand : ManagementCmdletBase
102102
/// </summary>
103103
protected override void ProcessRecordInternal()
104104
{
105-
WriteWarning("This output of this cmdlet will change in the next release to return a single object that includes the newly created object.");
106105
AutoscaleSettingResource parameters = this.CreateAutoscaleSettingResource();
107106

108107
// The result of this operation is operation (AutoscaleSettingResource) is being discarded for backwards compatibility
109108
var result = this.MonitorManagementClient.AutoscaleSettings.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name, parameters: parameters).Result;
110-
111-
// Keep this response for backwards compatibility.
112-
// Note: Create operations return the newly created object in the new specification, i.e. need to use result.Body
113-
var response = new List<AzureOperationResponse>
109+
var response = new PSAddAutoscaleSettingOperationResponse()
114110
{
115-
new AzureOperationResponse()
116-
{
117-
RequestId = result.RequestId,
118-
StatusCode = result.Response != null ? result.Response.StatusCode : HttpStatusCode.OK
119-
}
111+
RequestId = result.RequestId,
112+
StatusCode = result.Response != null ? result.Response.StatusCode : HttpStatusCode.OK,
113+
SettingSpec = result.Body
120114
};
121115

122116
WriteObject(response);

0 commit comments

Comments
 (0)