diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/AddAutoscaleSettingCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/AddAutoscaleSettingCommandTests.cs index 0a0e5cb30331..a65125dda754 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/AddAutoscaleSettingCommandTests.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/AddAutoscaleSettingCommandTests.cs @@ -20,7 +20,6 @@ using System.Threading.Tasks; using Hyak.Common; using Microsoft.Azure.Commands.Insights.Autoscale; -using Microsoft.Azure.Commands.Insights.OutputClasses; using Microsoft.Azure.Management.Insights; using Microsoft.Azure.Management.Insights.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/GetAutoscaleHistoryCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/GetAutoscaleHistoryCommandTests.cs index 45a413825b79..0feaff3f227d 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/GetAutoscaleHistoryCommandTests.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Autoscale/GetAutoscaleHistoryCommandTests.cs @@ -68,7 +68,7 @@ public void GetAutoscaleHistoryCommandParametersProcessing() Test.Utilities.ExecuteVerifications( cmdlet: cmdlet, insinsightsEventOperationsMockightsClientMock: this.insightsEventOperationsMock, - requiredFieldName: "eventSource", + requiredFieldName: "category", requiredFieldValue: GetAutoscaleHistoryCommand.AutoscaleEventSourceName, filter: ref this.filter, selected: ref this.selected, diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/GetDiagnosticSettingCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/GetDiagnosticSettingCommandTests.cs index 4ea869d9b200..241be3cbe6ef 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/GetDiagnosticSettingCommandTests.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/GetDiagnosticSettingCommandTests.cs @@ -18,7 +18,6 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -using Microsoft.Azure.Commands.Insights.Alerts; using Microsoft.Azure.Commands.Insights.Diagnostics; using Microsoft.Azure.Management.Insights; using Microsoft.Azure.Management.Insights.Models; @@ -35,7 +34,6 @@ public class GetDiagnosticSettingCommandTests private readonly Mock insightsDiagnosticsOperationsMock; private Mock commandRuntimeMock; private ServiceDiagnosticSettingsGetResponse response; - private RuleCreateOrUpdateParameters createOrUpdatePrms; private const string resourceId = "/subscriptions/123/resourcegroups/rg/providers/rp/resource/myresource"; private string calledResourceId; diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/SetDiagnosticSettingCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/SetDiagnosticSettingCommandTests.cs index 57de79075cba..58037df0bac9 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/SetDiagnosticSettingCommandTests.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Diagnostics/SetDiagnosticSettingCommandTests.cs @@ -14,18 +14,13 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Management.Automation; using System.Net; -using System.Threading; using System.Threading.Tasks; -using Microsoft.Azure.Commands.Insights.Alerts; using Microsoft.Azure.Commands.Insights.Diagnostics; using Microsoft.Azure.Management.Insights; using Microsoft.Azure.Management.Insights.Models; -using Microsoft.WindowsAzure.Commands.ScenarioTest; using Moq; -using Xunit; namespace Microsoft.Azure.Commands.Insights.Test.Diagnostics { @@ -36,7 +31,6 @@ public class SetDiagnosticSettingCommandTests private readonly Mock insightsDiagnosticsOperationsMock; private Mock commandRuntimeMock; private ServiceDiagnosticSettingsGetResponse response; - private RuleCreateOrUpdateParameters createOrUpdatePrms; private const string resourceId = "/subscriptions/123/resourcegroups/rg/providers/rp/resource/myresource"; private const string storageAccountId = "/subscriptions/123/resourcegroups/rg/providers/microsoft.storage/accounts/myaccount"; private string calledResourceId; diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricDefinitionsCommandTests.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricDefinitionsCommandTests.cs index de0b7abd2eb5..198bd0a8cd29 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricDefinitionsCommandTests.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Metrics/GetMetricDefinitionsCommandTests.cs @@ -12,7 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; using System.Management.Automation; using System.Threading; using System.Threading.Tasks; diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs b/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs index a2eae5dd9487..5456b2e8564d 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs +++ b/src/ResourceManager/Insights/Commands.Insights.Test/Utilities.cs @@ -218,7 +218,7 @@ public static void VerifyConditionInFilter(string filter, string field, string v if (!string.IsNullOrWhiteSpace(field)) { var condition = string.Format("and {0} eq '{1}'", field, value); - Assert.True(filter.Contains(condition), "Filter does not contain required condition"); + Assert.True(filter.Contains(condition), string.Format("Filter: {0} does not contain required condition: {1}", filter, condition)); } } diff --git a/src/ResourceManager/Insights/Commands.Insights.Test/packages.config b/src/ResourceManager/Insights/Commands.Insights.Test/packages.config index b7456da58e70..d2653ce3cdbb 100644 --- a/src/ResourceManager/Insights/Commands.Insights.Test/packages.config +++ b/src/ResourceManager/Insights/Commands.Insights.Test/packages.config @@ -24,7 +24,7 @@ - + diff --git a/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommand.cs index 884e81b8849f..49f2f9e7dd4a 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommand.cs @@ -166,6 +166,7 @@ private ManagementEventRuleCondition CreateEventRuleCondition() private void VerifyRuleTypeToParametersConsistency() { + WriteVerboseWithTimestamp(string.Format("VerifyRuleTypeToParametersConsistency: input type:{0}", this.RuleType)); AlertRuleTypes type = AlertRuleTypes.Event; // NOTE: the parameters EventName and MetricName cannot appear both at same time (see the parameters declaration), but they can be both absent simultaneously (i.e. Webtest data source type) @@ -209,12 +210,15 @@ private RuleCondition CreateRuleCondition() switch (this.RuleType) { case AlertRuleTypes.Event: + WriteVerboseWithTimestamp(string.Format("CreateRuleCondition: Creating event rule condition (event-based rule)")); condition = this.CreateEventRuleCondition(); break; case AlertRuleTypes.Metric: + WriteVerboseWithTimestamp(string.Format("CreateRuleCondition: Creating threshold rule condition (metric-based rule")); condition = this.CreateThresholdRuleCondition(); break; case AlertRuleTypes.Webtest: + WriteVerboseWithTimestamp(string.Format("CreateRuleCondition: Creating location threshold rule condition (webtest rule)")); condition = new LocationThresholdRuleCondition() { DataSource = new RuleMetricDataSource(), @@ -234,6 +238,8 @@ protected override RuleCreateOrUpdateParameters CreateSdkCallParameters() this.VerifyRuleTypeToParametersConsistency(); RuleCondition condition = this.CreateRuleCondition(); + + WriteVerboseWithTimestamp(string.Format("CreateSdkCallParameters: Creating rule object")); return new RuleCreateOrUpdateParameters() { Location = this.Location, diff --git a/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommandBase.cs b/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommandBase.cs index fbecf719f2b1..050f2ffa2598 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommandBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Alerts/AddAlertRuleCommandBase.cs @@ -116,7 +116,10 @@ public abstract class AddAlertRuleCommandBase : ManagementCmdletBase /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + RuleCreateOrUpdateParameters parameters = this.CreateSdkCallParameters(); + var result = this.InsightsManagementClient.AlertOperations.CreateOrUpdateRuleAsync(resourceGroupName: this.ResourceGroup, parameters: parameters).Result; WriteObject(result); } diff --git a/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertHistoryCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertHistoryCommand.cs index 2f4f14d9cd95..23fc661fff64 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertHistoryCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertHistoryCommand.cs @@ -71,6 +71,8 @@ protected override bool KeepTheRecord(EventData record) /// Modified query filter including the condition for eventSource protected override string ProcessParticularParameters(string currentQueryFilter) { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + // Make sure only events for alerts come back return this.AddConditionIfPResent(currentQueryFilter, "eventSource", AlertsEventSourceName); } diff --git a/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertRuleCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertRuleCommand.cs index abce4914e73d..af193130cc6d 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertRuleCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Alerts/GetAlertRuleCommand.cs @@ -71,6 +71,8 @@ public class GetAlertRuleCommand : ManagementCmdletBase /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + if (string.IsNullOrWhiteSpace(this.Name)) { // Retrieve all the AlertRules for a ResourceGroup @@ -83,6 +85,7 @@ protected override void ProcessRecordInternal() { // Retrieve a single AlertRule determined by the ResourceGroup and the rule name RuleGetResponse result = this.InsightsManagementClient.AlertOperations.GetRuleAsync(resourceGroupName: this.ResourceGroup, ruleName: this.Name).Result; + var finalResult = new List { this.DetailedOutput.IsPresent ? (PSManagementItemDescriptor)new PSAlertRule(result) : new PSAlertRuleNoDetails(result) }; WriteObject(sendToPipeline: finalResult); } diff --git a/src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAlertRuleCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAlertRuleCommand.cs index 4840c9925e85..d086c945a75e 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAlertRuleCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Alerts/RemoveAlertRuleCommand.cs @@ -12,7 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; using System.Collections.Generic; using System.Management.Automation; using Microsoft.Azure.Management.Insights; @@ -50,6 +49,8 @@ public class RemoveAlertRuleCommand : ManagementCmdletBase /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + AzureOperationResponse result = this.InsightsManagementClient.AlertOperations.DeleteRuleAsync(resourceGroupName: this.ResourceGroup, ruleName: this.Name).Result; WriteObject(result); } diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAutoscaleSettingCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAutoscaleSettingCommand.cs index 6d1fdaf7cbcb..1696912f2bdf 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAutoscaleSettingCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/AddAutoscaleSettingCommand.cs @@ -17,7 +17,6 @@ using System.Linq; using System.Management.Automation; using Hyak.Common; -using Microsoft.Azure.Commands.Insights.OutputClasses; using Microsoft.Azure.Commands.Insights.Properties; using Microsoft.Azure.Management.Insights; using Microsoft.Azure.Management.Insights.Models; @@ -94,7 +93,10 @@ public class AddAutoscaleSettingCommand : ManagementCmdletBase /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + AutoscaleSettingCreateOrUpdateParameters parameters = this.CreateSdkCallParameters(); + var result = this.InsightsManagementClient.AutoscaleOperations.CreateOrUpdateSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name, parameters: parameters).Result; WriteObject(result); @@ -106,6 +108,7 @@ private AutoscaleSettingCreateOrUpdateParameters CreateSdkCallParameters() if (this.SettingSpec != null) { + // Receiving a single parameter with the whole spec for an autoscale setting var property = this.SettingSpec.Properties; diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleHistoryCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleHistoryCommand.cs index ee76d616367f..bc12a3965bae 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleHistoryCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleHistoryCommand.cs @@ -71,6 +71,8 @@ protected override bool KeepTheRecord(EventData record) /// Modified query filter including the condition for eventSource protected override string ProcessParticularParameters(string currentQueryFilter) { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + return this.AddConditionIfPResent(currentQueryFilter, "category", AutoscaleEventSourceName); } } diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleSettingCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleSettingCommand.cs index ba2ed6557f8b..01f83145835c 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleSettingCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/GetAutoscaleSettingCommand.cs @@ -12,7 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; using System.Collections.Generic; using System.Linq; using System.Management.Automation; @@ -59,6 +58,8 @@ public class GetAutoscaleSettingCommand : ManagementCmdletBase /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + if (string.IsNullOrWhiteSpace(this.Name)) { // Retrieve all the Autoscale settings for a resource group @@ -71,6 +72,7 @@ protected override void ProcessRecordInternal() { // Retrieve a single Autoscale setting determined by the resource group and the rule name AutoscaleSettingGetResponse result = this.InsightsManagementClient.AutoscaleOperations.GetSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name).Result; + WriteObject(sendToPipeline: this.DetailedOutput.IsPresent ? new PSAutoscaleSetting(result) : result.ToAutoscaleSettingGetResponse()); } } diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleProfileCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleProfileCommand.cs index 48d3ccb45bb2..b03485987b4c 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleProfileCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleProfileCommand.cs @@ -136,6 +136,8 @@ public class NewAutoscaleProfileCommand : AzureRMCmdlet /// public override void ExecuteCmdlet() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + AutoscaleProfile profile = this.CreateSettingProfile(); WriteObject(profile); } diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleRuleCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleRuleCommand.cs index aaf778def49f..cf052256c50d 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleRuleCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/NewAutoscaleRuleCommand.cs @@ -13,13 +13,10 @@ // ---------------------------------------------------------------------------------- using System; -using System.Collections.Generic; -using System.Globalization; using System.Management.Automation; using Microsoft.Azure.Commands.Insights.Properties; using Microsoft.Azure.Commands.ResourceManager.Common; using Microsoft.Azure.Management.Insights.Models; -using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Commands.Insights.Autoscale { @@ -116,6 +113,8 @@ public class NewAutoscaleRuleCommand : AzureRMCmdlet /// public override void ExecuteCmdlet() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + ScaleRule rule = this.CreateSettingRule(); WriteObject(rule); } diff --git a/src/ResourceManager/Insights/Commands.Insights/Autoscale/RemoveAutoscaleSettingCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Autoscale/RemoveAutoscaleSettingCommand.cs index 4569787b4579..e689f79f7fee 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Autoscale/RemoveAutoscaleSettingCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Autoscale/RemoveAutoscaleSettingCommand.cs @@ -12,8 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Management.Automation; using Microsoft.Azure.Management.Insights; @@ -50,6 +48,8 @@ public class RemoveAutoscaleSettingCommand : ManagementCmdletBase /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + AzureOperationResponse result = this.InsightsManagementClient.AutoscaleOperations.DeleteSettingAsync(resourceGroupName: this.ResourceGroup, autoscaleSettingName: this.Name).Result; WriteObject(result); } diff --git a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj index 9586fc91fc38..88497b9f9dd3 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj +++ b/src/ResourceManager/Insights/Commands.Insights/Commands.Insights.csproj @@ -79,7 +79,7 @@ ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll True - + ..\..\..\packages\Microsoft.Rest.ClientRuntime.2.0.1\lib\net45\Microsoft.Rest.ClientRuntime.dll True diff --git a/src/ResourceManager/Insights/Commands.Insights/Diagnostics/GetAzureRmDiagnosticSettingCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Diagnostics/GetAzureRmDiagnosticSettingCommand.cs index 5eb4471de2cc..c20951370bdc 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Diagnostics/GetAzureRmDiagnosticSettingCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Diagnostics/GetAzureRmDiagnosticSettingCommand.cs @@ -12,8 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; -using System.Collections.Generic; using System.Management.Automation; using System.Threading; using Microsoft.Azure.Commands.Insights.OutputClasses; diff --git a/src/ResourceManager/Insights/Commands.Insights/Diagnostics/SetAzureRmDiagnosticSettingCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Diagnostics/SetAzureRmDiagnosticSettingCommand.cs index a96292157d86..4743dceddc4e 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Diagnostics/SetAzureRmDiagnosticSettingCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Diagnostics/SetAzureRmDiagnosticSettingCommand.cs @@ -13,7 +13,6 @@ // ---------------------------------------------------------------------------------- using System; -using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; diff --git a/src/ResourceManager/Insights/Commands.Insights/InsightsCmdletBase.cs b/src/ResourceManager/Insights/Commands.Insights/InsightsCmdletBase.cs index 666fb9857517..12d7d3cd0bfb 100644 --- a/src/ResourceManager/Insights/Commands.Insights/InsightsCmdletBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/InsightsCmdletBase.cs @@ -14,7 +14,6 @@ using System; using Microsoft.Azure.Commands.ResourceManager.Common; -using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Commands.Insights { diff --git a/src/ResourceManager/Insights/Commands.Insights/ManagementCmdletBase.cs b/src/ResourceManager/Insights/Commands.Insights/ManagementCmdletBase.cs index b41097f6058b..74f909a30d3b 100644 --- a/src/ResourceManager/Insights/Commands.Insights/ManagementCmdletBase.cs +++ b/src/ResourceManager/Insights/Commands.Insights/ManagementCmdletBase.cs @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Commands.Insights /// /// Base class for the Azure Insights SDK Cmdlets based on the InsightsManagementClient /// - public abstract class ManagementCmdletBase : InsightsCmdletBase, IDisposable + public abstract class ManagementCmdletBase : InsightsCmdletBase { #region General declarations @@ -35,11 +35,11 @@ public abstract class ManagementCmdletBase : InsightsCmdletBase, IDisposable /// public IInsightsManagementClient InsightsManagementClient { - get - { + // The premise is that a command to establish a context (like Add-AzureRmAccount) has + // been called before this command in order to have a correct CurrentContext + get { if (this.insightsManagementClient == null) { - // The premise is that a command to establish a context (like Add-AzureRmAccount) has been called before this command in order to have a correct CurrentContext this.insightsManagementClient = AzureSession.ClientFactory.CreateClient(DefaultProfile.Context, AzureEnvironment.Endpoint.ResourceManager); } diff --git a/src/ResourceManager/Insights/Commands.Insights/Metrics/FormatMetricsAsTableCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Metrics/FormatMetricsAsTableCommand.cs index ee62393a077b..8e24cd4fe95c 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Metrics/FormatMetricsAsTableCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Metrics/FormatMetricsAsTableCommand.cs @@ -18,7 +18,6 @@ using Microsoft.Azure.Commands.Insights.OutputClasses; using Microsoft.Azure.Commands.ResourceManager.Common; using Microsoft.Azure.Insights.Models; -using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Commands.Insights.Metrics { @@ -77,6 +76,8 @@ public PSMetricTabularResult[] ProcessParameter() /// public override void ExecuteCmdlet() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + WriteObject(this.ProcessParameter()); } } diff --git a/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricDefinitionsCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricDefinitionsCommand.cs index e93d5eeb94f0..69f5509fd03c 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricDefinitionsCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricDefinitionsCommand.cs @@ -12,7 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; using System.Linq; using System.Management.Automation; using System.Text; @@ -71,12 +70,15 @@ protected string ProcessParameters() /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + string queryFilter = this.ProcessParameters(); bool fullDetails = this.DetailedOutput.IsPresent; // Call the proper API methods to return a list of raw records. // If fullDetails is present full details of the records are displayed, otherwise only a summary of the records is displayed MetricDefinitionListResponse response = this.InsightsClient.MetricDefinitionOperations.GetMetricDefinitionsAsync(resourceUri: this.ResourceId, filterString: queryFilter, cancellationToken: CancellationToken.None).Result; + var records = response.MetricDefinitionCollection.Value.Select(e => fullDetails ? (MetricDefinition)new PSMetricDefinition(e) : new PSMetricDefinitionNoDetails(e)).ToArray(); WriteObject(sendToPipeline: records); diff --git a/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricsCommand.cs b/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricsCommand.cs index ffe2df550350..ec43d3cd384e 100644 --- a/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricsCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/Metrics/GetMetricsCommand.cs @@ -127,12 +127,15 @@ protected string ProcessParameters() /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + string queryFilter = this.ProcessParameters(); bool fullDetails = this.DetailedOutput.IsPresent; // Call the proper API methods to return a list of raw records. // If fullDetails is present full details of the records displayed, otherwise only a summary of the values is displayed MetricListResponse response = this.InsightsClient.MetricOperations.GetMetricsAsync(resourceUri: this.ResourceId, filterString: queryFilter, cancellationToken: CancellationToken.None).Result; + var records = response.MetricCollection.Value.Select(e => fullDetails ? (Metric)new PSMetric(e) : new PSMetricNoDetails(e)).ToArray(); WriteObject(sendToPipeline: records); diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/CustomPrinter.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/CustomPrinter.cs index 8c4aad18367e..5a72a024eff4 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/CustomPrinter.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/CustomPrinter.cs @@ -1,4 +1,18 @@ -using System; +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; using System.Collections; using System.Linq; using System.Reflection; diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSLogSettings.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSLogSettings.cs index d5743144a120..fae5bd4af951 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSLogSettings.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSLogSettings.cs @@ -12,8 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.Xml; using Microsoft.Azure.Management.Insights.Models; namespace Microsoft.Azure.Commands.Insights.OutputClasses diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricSettings.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricSettings.cs index c40d15ace0be..8364a38e8a5b 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricSettings.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricSettings.cs @@ -12,7 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System.Collections.Generic; using System.Xml; using Microsoft.Azure.Management.Insights.Models; diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValue.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValue.cs index 9e6116f10efa..3077f1939b74 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValue.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSMetricValue.cs @@ -12,7 +12,6 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System.Text; using Microsoft.Azure.Insights.Models; namespace Microsoft.Azure.Commands.Insights.OutputClasses diff --git a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSToStringExtensions.cs b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSToStringExtensions.cs index 729a5c666966..cc9e6bd263fc 100644 --- a/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSToStringExtensions.cs +++ b/src/ResourceManager/Insights/Commands.Insights/OutputClasses/PSToStringExtensions.cs @@ -12,12 +12,8 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; -using System.Collections; using System.Collections.Generic; -using System.Reflection; using System.Text; -using System.Xml; using Hyak.Common; using Microsoft.Azure.Insights.Models; using Microsoft.Azure.Management.Insights.Models; diff --git a/src/ResourceManager/Insights/Commands.Insights/UsageMetrics/GetUsageMetricsCommand.cs b/src/ResourceManager/Insights/Commands.Insights/UsageMetrics/GetUsageMetricsCommand.cs index 5deb854d53d7..0f63099c3b4c 100644 --- a/src/ResourceManager/Insights/Commands.Insights/UsageMetrics/GetUsageMetricsCommand.cs +++ b/src/ResourceManager/Insights/Commands.Insights/UsageMetrics/GetUsageMetricsCommand.cs @@ -121,6 +121,8 @@ protected string ProcessParameters() /// protected override void ProcessRecordInternal() { + WriteWarning("This cmdlet is being modified to enable better experience and may contain breaking changes in a future release."); + string queryFilter = this.ProcessParameters(); string apiVersion = this.ApiVersion ?? DefaultApiVersion; @@ -129,6 +131,7 @@ protected override void ProcessRecordInternal() UsageMetricListResponse response = this.InsightsClient.UsageMetricOperations .ListAsync(resourceUri: this.ResourceId, filterString: queryFilter, apiVersion: apiVersion, cancellationToken: CancellationToken.None) .Result; + var records = response.UsageMetricCollection.Value .Select(e => new PSUsageMetric(e)) .ToArray(); diff --git a/src/ResourceManager/Insights/Insights.sln b/src/ResourceManager/Insights/Insights.sln index 806b57527702..7df1364abacf 100644 --- a/src/ResourceManager/Insights/Insights.sln +++ b/src/ResourceManager/Insights/Insights.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +VisualStudioVersion = 12.0.30723.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{95C16AED-FD57-42A0-86C3-2CF4300A4817}" EndProject