From 497703b6bed0b2a47b7379f3d470713a925fb5d8 Mon Sep 17 00:00:00 2001 From: JoyerJin <116236375+JoyerJin@users.noreply.github.com> Date: Mon, 23 Dec 2024 10:24:58 +0800 Subject: [PATCH] generate autorest csharp --- .../Generated/ActivityLogsOperations.cs | 431 +++++ .../ActivityLogsOperationsExtensions.cs | 112 ++ .../Generated/AlertRulesOperations.cs | 1306 +++++++++++++ .../AlertRulesOperationsExtensions.cs | 260 +++ .../Generated/AutoscaleSettingsOperations.cs | 1624 ++++++++++++++++ .../AutoscaleSettingsOperationsExtensions.cs | 326 ++++ .../Generated/BaselinesOperations.cs | 310 +++ .../BaselinesOperationsExtensions.cs | 143 ++ .../Generated/DiagnosticSettingsOperations.cs | 774 ++++++++ .../DiagnosticSettingsOperationsExtensions.cs | 182 ++ .../Generated/EventCategoriesOperations.cs | 216 +++ .../EventCategoriesOperationsExtensions.cs | 59 + .../Generated/IActivityLogsOperations.cs | 82 + .../Generated/IAlertRulesOperations.cs | 172 ++ .../Generated/IAutoscaleSettingsOperations.cs | 216 +++ .../Generated/IBaselinesOperations.cs | 93 + .../IDiagnosticSettingsOperations.cs | 125 ++ .../Generated/IEventCategoriesOperations.cs | 49 + .../Generated/ILogProfilesOperations.cs | 138 ++ .../Generated/IMetricAlertsOperations.cs | 171 ++ .../IMetricAlertsStatusOperations.cs | 80 + .../Generated/IMetricDefinitionsOperations.cs | 52 + .../Generated/IMetricNamespacesOperations.cs | 53 + .../Generated/IMetricsOperations.cs | 87 + .../Generated/IMonitorManagementClient.cs | 153 ++ .../IPrivateEndpointConnectionsOperations.cs | 212 +++ .../IPrivateLinkResourcesOperations.cs | 105 + ...ivateLinkScopeOperationStatusOperations.cs | 53 + .../IPrivateLinkScopedResourcesOperations.cs | 214 +++ .../Generated/IPrivateLinkScopesOperations.cs | 245 +++ .../Generated/LogProfilesOperations.cs | 1007 ++++++++++ .../LogProfilesOperationsExtensions.cs | 202 ++ .../Generated/MetricAlertsOperations.cs | 1269 +++++++++++++ .../MetricAlertsOperationsExtensions.cs | 258 +++ .../Generated/MetricAlertsStatusOperations.cs | 477 +++++ .../MetricAlertsStatusOperationsExtensions.cs | 111 ++ .../Generated/MetricDefinitionsOperations.cs | 237 +++ .../MetricDefinitionsOperationsExtensions.cs | 67 + .../Generated/MetricNamespacesOperations.cs | 238 +++ .../MetricNamespacesOperationsExtensions.cs | 69 + .../Generated/MetricsOperations.cs | 315 +++ .../Generated/MetricsOperationsExtensions.cs | 132 ++ .../Generated/Models/AggregationType.cs | 84 + .../Generated/Models/AggregationTypeEnum.cs | 25 + .../Generated/Models/AlertRuleResource.cs | 149 ++ .../Models/AlertRuleResourcePatch.cs | 149 ++ .../Generated/Models/AutoscaleNotification.cs | 76 + .../Generated/Models/AutoscaleProfile.cs | 140 ++ .../Models/AutoscaleSettingResource.cs | 143 ++ .../Models/AutoscaleSettingResourcePatch.cs | 145 ++ .../Models/AzureMonitorPrivateLinkScope.cs | 100 + .../Generated/Models/BaselineMetadata.cs | 77 + .../Generated/Models/BaselineSensitivity.cs | 23 + .../Models/ComparisonOperationType.cs | 84 + .../Generated/Models/ConditionOperator.cs | 72 + .../Models/DiagnosticSettingsResource.cs | 139 ++ .../DiagnosticSettingsResourceCollection.cs | 56 + .../Generated/Models/DynamicMetricCriteria.cs | 134 ++ .../Models/DynamicThresholdFailingPeriods.cs | 80 + .../Models/DynamicThresholdOperator.cs | 23 + .../Models/DynamicThresholdSensitivity.cs | 23 + .../Generated/Models/EmailNotification.cs | 76 + .../Generated/Models/ErrorAdditionalInfo.cs | 59 + .../Generated/Models/ErrorResponse.cs | 60 + .../Generated/Models/ErrorResponseCommon.cs | 65 + .../Models/ErrorResponseCommonException.cs | 62 + .../Models/ErrorResponseException.cs | 62 + .../Generated/Models/EventData.cs | 339 ++++ .../Generated/Models/EventLevel.cs | 78 + .../Generated/Models/HttpRequestInfo.cs | 75 + .../Generated/Models/LocalizableString.cs | 73 + .../Models/LocationThresholdRuleCondition.cs | 87 + .../Generated/Models/LogProfileResource.cs | 138 ++ .../Models/LogProfileResourcePatch.cs | 139 ++ .../Generated/Models/LogSettings.cs | 89 + .../ManagementEventAggregationCondition.cs | 78 + .../Models/ManagementEventRuleCondition.cs | 64 + .../Generated/Models/MetadataValue.cs | 72 + .../Generated/Models/Metric.cs | 159 ++ .../Generated/Models/MetricAlertAction.cs | 66 + .../Generated/Models/MetricAlertCriteria.cs | 56 + ...tMultipleResourceMultipleMetricCriteria.cs | 62 + .../Generated/Models/MetricAlertResource.cs | 205 ++ .../Models/MetricAlertResourcePatch.cs | 187 ++ ...ertSingleResourceMultipleMetricCriteria.cs | 62 + .../Generated/Models/MetricAlertStatus.cs | 77 + .../Models/MetricAlertStatusCollection.cs | 56 + .../Models/MetricAlertStatusProperties.cs | 73 + .../Generated/Models/MetricAvailability.cs | 66 + .../Generated/Models/MetricClass.cs | 25 + .../Generated/Models/MetricCriteria.cs | 95 + .../Generated/Models/MetricDefinition.cs | 201 ++ .../Generated/Models/MetricDimension.cs | 93 + .../Generated/Models/MetricNamespace.cs | 87 + .../Generated/Models/MetricNamespaceName.cs | 52 + .../Generated/Models/MetricSettings.cs | 98 + .../Generated/Models/MetricSingleDimension.cs | 77 + .../Generated/Models/MetricStatisticType.cs | 78 + .../Generated/Models/MetricTrigger.cs | 208 ++ .../Generated/Models/MetricUnit.cs | 33 + .../Generated/Models/MetricValue.cs | 107 ++ .../Generated/Models/MultiMetricCriteria.cs | 142 ++ .../Models/NamespaceClassification.cs | 23 + .../Generated/Models/OperationStatus.cs | 94 + .../Generated/Models/OperatorModel.cs | 25 + .../Generated/Models/Page.cs | 53 + .../Generated/Models/Page1.cs | 53 + .../Models/PrivateEndpointConnection.cs | 90 + .../Models/PrivateEndpointProperty.cs | 51 + .../Generated/Models/PrivateLinkResource.cs | 69 + .../Models/PrivateLinkScopesResource.cs | 100 + ...ivateLinkServiceConnectionStateProperty.cs | 90 + .../Generated/Models/ProxyOnlyResource.cs | 69 + .../Generated/Models/ProxyResource.cs | 69 + .../Generated/Models/Recurrence.cs | 92 + .../Generated/Models/RecurrenceFrequency.cs | 96 + .../Generated/Models/RecurrentSchedule.cs | 194 ++ .../Generated/Models/Resource.cs | 100 + .../Generated/Models/Response.cs | 144 ++ .../Generated/Models/ResultType.cs | 60 + .../Generated/Models/RetentionPolicy.cs | 77 + .../Generated/Models/RuleAction.cs | 38 + .../Generated/Models/RuleCondition.cs | 56 + .../Generated/Models/RuleDataSource.cs | 85 + .../Generated/Models/RuleEmailAction.cs | 69 + .../RuleManagementEventClaimsDataSource.cs | 53 + .../Models/RuleManagementEventDataSource.cs | 136 ++ .../Generated/Models/RuleMetricDataSource.cs | 65 + .../Generated/Models/RuleWebhookAction.cs | 68 + .../Generated/Models/ScaleAction.cs | 101 + .../Generated/Models/ScaleCapacity.cs | 99 + .../Generated/Models/ScaleDirection.cs | 66 + .../Generated/Models/ScaleRule.cs | 87 + .../Models/ScaleRuleMetricDimension.cs | 99 + .../ScaleRuleMetricDimensionOperationType.cs | 22 + .../Generated/Models/ScaleType.cs | 72 + .../Generated/Models/ScopedResource.cs | 68 + .../Generated/Models/SenderAuthorization.cs | 72 + .../Generated/Models/SingleBaseline.cs | 95 + .../Generated/Models/SingleMetricBaseline.cs | 160 ++ .../Generated/Models/TagsResource.cs | 54 + .../Models/ThresholdRuleCondition.cs | 106 ++ .../Models/TimeAggregationOperator.cs | 78 + .../Generated/Models/TimeAggregationType.cs | 84 + .../Generated/Models/TimeSeriesBaseline.cs | 141 ++ .../Generated/Models/TimeSeriesElement.cs | 68 + .../Generated/Models/TimeWindow.cs | 162 ++ .../Generated/Models/WebhookNotification.cs | 63 + .../WebtestLocationAvailabilityCriteria.cs | 96 + .../Generated/MonitorManagementClient.cs | 460 +++++ .../PrivateEndpointConnectionsOperations.cs | 1150 +++++++++++ ...EndpointConnectionsOperationsExtensions.cs | 331 ++++ .../PrivateLinkResourcesOperations.cs | 663 +++++++ ...rivateLinkResourcesOperationsExtensions.cs | 151 ++ ...ivateLinkScopeOperationStatusOperations.cs | 267 +++ ...copeOperationStatusOperationsExtensions.cs | 67 + .../PrivateLinkScopedResourcesOperations.cs | 1167 ++++++++++++ ...LinkScopedResourcesOperationsExtensions.cs | 335 ++++ .../Generated/PrivateLinkScopesOperations.cs | 1690 +++++++++++++++++ .../PrivateLinkScopesOperationsExtensions.cs | 371 ++++ .../SdkInfo_MonitorManagementClient.cs | 43 + .../Monitor.Management.Sdk.csproj | 13 + .../Properties/AssemblyInfo.cs | 29 + src/Monitor/Monitor.Management.Sdk/README.md | 123 ++ src/Monitor/Monitor.Test/Monitor.Test.csproj | 2 +- src/Monitor/Monitor.sln | 58 +- src/Monitor/Monitor/Az.Monitor.psd1 | 2 +- src/Monitor/Monitor/Monitor.csproj | 6 +- .../OutputClasses/PSActionGroupProperty.cs | 116 -- .../OutputClasses/PSActionGroupResource.cs | 150 -- .../PSAddActionGroupOperationResponse.cs | 25 - .../OutputClasses/PSArmRoleReceiver.cs | 46 - .../PSAutomationRunbookReceiver.cs | 62 - .../OutputClasses/PSAutoscaleProfilesList.cs | 37 - .../OutputClasses/PSAutoscaleSetting.cs | 39 - .../PSAutoscaleSettingNoDetails.cs | 33 - .../OutputClasses/PSAzureAppPushReceiver.cs | 45 - .../OutputClasses/PSAzureFunctionReceiver.cs | 60 - .../PSDataCollectionRuleResource.cs | 658 ------- .../PSDiagnosticSettingCategory.cs | 39 - .../PSDiagnosticSettingOperationResponse.cs | 29 - .../Monitor/OutputClasses/PSEmailReceiver.cs | 57 - .../OutputClasses/PSEventHubReceiver.cs | 61 - .../Monitor/OutputClasses/PSItsmReceiver.cs | 55 - .../OutputClasses/PSLogicAppReceiver.cs | 54 - .../Monitor/OutputClasses/PSMetricSettings.cs | 73 - .../PSScheduledQueryRuleAlertingAction.cs | 26 - .../PSScheduledQueryRuleAznsAction.cs | 25 - .../PSScheduledQueryRuleLogMetricTrigger.cs | 29 - .../PSScheduledQueryRuleResource.cs | 25 - .../PSScheduledQueryRuleSchedule.cs | 25 - .../PSScheduledQueryRuleSource.cs | 25 - .../PSScheduledQueryRuleTriggerCondition.cs | 25 - .../PSServiceDiagnosticSettings.cs | 86 - .../Monitor/OutputClasses/PSSmsReceiver.cs | 56 - .../PSTestNotificationDetailsResponse.cs | 56 - .../PSTestNotificationResource.cs | 141 -- .../OutputClasses/PSThresholdRuleCondition.cs | 80 - .../Monitor/OutputClasses/PSVoiceReceiver.cs | 47 - .../OutputClasses/PSWebhookReceiver.cs | 74 - .../TransitionalClasses/MetricSettings.cs | 53 - .../ScheduledQueryRuleAlertingAction.cs | 34 - .../ScheduledQueryRuleAznsAction.cs | 33 - .../ScheduledQueryRuleMetricTrigger.cs | 34 - .../ScheduledQueryRuleResource.cs | 42 - .../ScheduledQueryRuleSchedule.cs | 32 - .../ScheduledQueryRuleSource.cs | 38 - .../ScheduledQueryRuleTriggerCondition.cs | 33 - .../TransitionalClasses/TransitionHelpers.cs | 22 - 209 files changed, 28937 insertions(+), 2711 deletions(-) create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/ActivityLogsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/ActivityLogsOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/AlertRulesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/AlertRulesOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/AutoscaleSettingsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/AutoscaleSettingsOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/BaselinesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/BaselinesOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/DiagnosticSettingsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/DiagnosticSettingsOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/EventCategoriesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/EventCategoriesOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IActivityLogsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IAlertRulesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IAutoscaleSettingsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IBaselinesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IDiagnosticSettingsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IEventCategoriesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/ILogProfilesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IMetricAlertsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IMetricAlertsStatusOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IMetricDefinitionsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IMetricNamespacesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IMetricsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IMonitorManagementClient.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IPrivateEndpointConnectionsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkResourcesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopeOperationStatusOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopedResourcesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/LogProfilesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/LogProfilesOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsStatusOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsStatusOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricDefinitionsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricDefinitionsOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricNamespacesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricNamespacesOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MetricsOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AggregationType.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AggregationTypeEnum.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AlertRuleResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AlertRuleResourcePatch.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleNotification.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleProfile.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleSettingResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleSettingResourcePatch.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/AzureMonitorPrivateLinkScope.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/BaselineMetadata.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/BaselineSensitivity.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ComparisonOperationType.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ConditionOperator.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/DiagnosticSettingsResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/DiagnosticSettingsResourceCollection.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicMetricCriteria.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdFailingPeriods.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdOperator.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdSensitivity.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/EmailNotification.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorAdditionalInfo.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponse.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseCommon.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseCommonException.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseException.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/EventData.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/EventLevel.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/HttpRequestInfo.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/LocalizableString.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/LocationThresholdRuleCondition.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/LogProfileResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/LogProfileResourcePatch.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/LogSettings.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ManagementEventAggregationCondition.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ManagementEventRuleCondition.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetadataValue.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/Metric.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertAction.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertCriteria.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertResourcePatch.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatus.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatusCollection.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatusProperties.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAvailability.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricClass.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricCriteria.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricDefinition.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricDimension.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricNamespace.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricNamespaceName.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricSettings.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricSingleDimension.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricStatisticType.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricTrigger.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricUnit.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricValue.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/MultiMetricCriteria.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/NamespaceClassification.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/OperationStatus.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/OperatorModel.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/Page.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/Page1.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateEndpointConnection.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateEndpointProperty.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkScopesResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ProxyOnlyResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ProxyResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/Recurrence.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RecurrenceFrequency.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RecurrentSchedule.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/Resource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/Response.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ResultType.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RetentionPolicy.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleAction.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleCondition.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleDataSource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleEmailAction.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleManagementEventClaimsDataSource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleManagementEventDataSource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleMetricDataSource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleWebhookAction.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleAction.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleCapacity.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleDirection.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRule.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRuleMetricDimension.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRuleMetricDimensionOperationType.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleType.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ScopedResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/SenderAuthorization.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/SingleBaseline.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/SingleMetricBaseline.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/TagsResource.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/ThresholdRuleCondition.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeAggregationOperator.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeAggregationType.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeSeriesBaseline.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeSeriesElement.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeWindow.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/WebhookNotification.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/Models/WebtestLocationAvailabilityCriteria.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/MonitorManagementClient.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateEndpointConnectionsOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateEndpointConnectionsOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkResourcesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkResourcesOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopeOperationStatusOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopeOperationStatusOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopedResourcesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopedResourcesOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopesOperations.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopesOperationsExtensions.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Generated/SdkInfo_MonitorManagementClient.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/Monitor.Management.Sdk.csproj create mode 100644 src/Monitor/Monitor.Management.Sdk/Properties/AssemblyInfo.cs create mode 100644 src/Monitor/Monitor.Management.Sdk/README.md delete mode 100644 src/Monitor/Monitor/OutputClasses/PSActionGroupProperty.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSActionGroupResource.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSAddActionGroupOperationResponse.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSArmRoleReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSAutomationRunbookReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSAutoscaleProfilesList.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSAutoscaleSetting.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSAutoscaleSettingNoDetails.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSAzureAppPushReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSAzureFunctionReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSDataCollectionRuleResource.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSDiagnosticSettingCategory.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSDiagnosticSettingOperationResponse.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSEmailReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSEventHubReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSItsmReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSLogicAppReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSMetricSettings.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleAlertingAction.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleAznsAction.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleLogMetricTrigger.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleResource.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleSchedule.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleSource.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleTriggerCondition.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSServiceDiagnosticSettings.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSSmsReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSTestNotificationDetailsResponse.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSTestNotificationResource.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSThresholdRuleCondition.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSVoiceReceiver.cs delete mode 100644 src/Monitor/Monitor/OutputClasses/PSWebhookReceiver.cs delete mode 100644 src/Monitor/Monitor/TransitionalClasses/MetricSettings.cs delete mode 100644 src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleAlertingAction.cs delete mode 100644 src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleAznsAction.cs delete mode 100644 src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleMetricTrigger.cs delete mode 100644 src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleResource.cs delete mode 100644 src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleSchedule.cs delete mode 100644 src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleSource.cs delete mode 100644 src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleTriggerCondition.cs diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/ActivityLogsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/ActivityLogsOperations.cs new file mode 100644 index 000000000000..8e4f078e958a --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/ActivityLogsOperations.cs @@ -0,0 +1,431 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ActivityLogsOperations operations. + /// + internal partial class ActivityLogsOperations : IServiceOperations, IActivityLogsOperations + { + /// + /// Initializes a new instance of the ActivityLogsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ActivityLogsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Provides the list of records from the activity logs. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(ODataQuery odataQuery, string select = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (odataQuery == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "odataQuery"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("select", select); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (select != null) + { + _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Provides the list of records from the activity logs. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/ActivityLogsOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/ActivityLogsOperationsExtensions.cs new file mode 100644 index 000000000000..ed039c9d08e2 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/ActivityLogsOperationsExtensions.cs @@ -0,0 +1,112 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ActivityLogsOperations. + /// + public static partial class ActivityLogsOperationsExtensions + { + /// + /// Provides the list of records from the activity logs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* + /// + public static IPage List(this IActivityLogsOperations operations, ODataQuery odataQuery, string select = default(string)) + { + return operations.ListAsync(odataQuery, select).GetAwaiter().GetResult(); + } + + /// + /// Provides the list of records from the activity logs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to be + /// returned. Possible values are: *authorization*, *claims*, *correlationId*, + /// *description*, *eventDataId*, *eventName*, *eventTimestamp*, *httpRequest*, + /// *level*, *operationId*, *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, *submissionTimestamp*, + /// *subStatus*, *subscriptionId* + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IActivityLogsOperations operations, ODataQuery odataQuery, string select = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(odataQuery, select, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Provides the list of records from the activity logs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IActivityLogsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Provides the list of records from the activity logs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IActivityLogsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/AlertRulesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/AlertRulesOperations.cs new file mode 100644 index 000000000000..f9008268502c --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/AlertRulesOperations.cs @@ -0,0 +1,1306 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AlertRulesOperations operations. + /// + internal partial class AlertRulesOperations : IServiceOperations, IAlertRulesOperations + { + /// + /// Initializes a new instance of the AlertRulesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AlertRulesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Creates or updates a classic metric alert rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, AlertRuleResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a classic metric alert rule + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a classic metric alert rule + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing classic metric AlertRuleResource. To update other + /// fields use the CreateOrUpdate method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (alertRulesResource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "alertRulesResource"); + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("alertRulesResource", alertRulesResource); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(alertRulesResource != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(alertRulesResource, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the classic metric alert rules within a resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the classic metric alert rules within a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/AlertRulesOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/AlertRulesOperationsExtensions.cs new file mode 100644 index 000000000000..a803ec871d91 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/AlertRulesOperationsExtensions.cs @@ -0,0 +1,260 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AlertRulesOperations. + /// + public static partial class AlertRulesOperationsExtensions + { + /// + /// Creates or updates a classic metric alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + public static AlertRuleResource CreateOrUpdate(this IAlertRulesOperations operations, string resourceGroupName, string ruleName, AlertRuleResource parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, ruleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a classic metric alert rule. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IAlertRulesOperations operations, string resourceGroupName, string ruleName, AlertRuleResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, ruleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a classic metric alert rule + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + public static void Delete(this IAlertRulesOperations operations, string resourceGroupName, string ruleName) + { + operations.DeleteAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a classic metric alert rule + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAlertRulesOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a classic metric alert rule + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + public static AlertRuleResource Get(this IAlertRulesOperations operations, string resourceGroupName, string ruleName) + { + return operations.GetAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Gets a classic metric alert rule + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAlertRulesOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing classic metric AlertRuleResource. To update other + /// fields use the CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Parameters supplied to the operation. + /// + public static AlertRuleResource Update(this IAlertRulesOperations operations, string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource) + { + return operations.UpdateAsync(resourceGroupName, ruleName, alertRulesResource).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing classic metric AlertRuleResource. To update other + /// fields use the CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAlertRulesOperations operations, string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, ruleName, alertRulesResource, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the classic metric alert rules within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + public static IEnumerable ListByResourceGroup(this IAlertRulesOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// List the classic metric alert rules within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IAlertRulesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the classic metric alert rules within a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscription(this IAlertRulesOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// List the classic metric alert rules within a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IAlertRulesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/AutoscaleSettingsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/AutoscaleSettingsOperations.cs new file mode 100644 index 000000000000..95b19aa4b48d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/AutoscaleSettingsOperations.cs @@ -0,0 +1,1624 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AutoscaleSettingsOperations operations. + /// + internal partial class AutoscaleSettingsOperations : IServiceOperations, IAutoscaleSettingsOperations + { + /// + /// Initializes a new instance of the AutoscaleSettingsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal AutoscaleSettingsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Lists the autoscale settings for a resource group + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates an autoscale setting. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (autoscaleSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "autoscaleSettingName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("autoscaleSettingName", autoscaleSettingName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{autoscaleSettingName}", System.Uri.EscapeDataString(autoscaleSettingName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes and autoscale setting + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (autoscaleSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "autoscaleSettingName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("autoscaleSettingName", autoscaleSettingName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{autoscaleSettingName}", System.Uri.EscapeDataString(autoscaleSettingName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets an autoscale setting + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (autoscaleSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "autoscaleSettingName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("autoscaleSettingName", autoscaleSettingName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{autoscaleSettingName}", System.Uri.EscapeDataString(autoscaleSettingName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing AutoscaleSettingsResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (autoscaleSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "autoscaleSettingName"); + } + if (autoscaleSettingResource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "autoscaleSettingResource"); + } + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("autoscaleSettingName", autoscaleSettingName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("autoscaleSettingResource", autoscaleSettingResource); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{autoscaleSettingName}", System.Uri.EscapeDataString(autoscaleSettingName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(autoscaleSettingResource != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(autoscaleSettingResource, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists the autoscale settings for a resource group + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/AutoscaleSettingsOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/AutoscaleSettingsOperationsExtensions.cs new file mode 100644 index 000000000000..e43d0fda5f27 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/AutoscaleSettingsOperationsExtensions.cs @@ -0,0 +1,326 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for AutoscaleSettingsOperations. + /// + public static partial class AutoscaleSettingsOperationsExtensions + { + /// + /// Lists the autoscale settings for a resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + public static IPage ListByResourceGroup(this IAutoscaleSettingsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Lists the autoscale settings for a resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IAutoscaleSettingsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates an autoscale setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + public static AutoscaleSettingResource CreateOrUpdate(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, autoscaleSettingName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates an autoscale setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, autoscaleSettingName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes and autoscale setting + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + public static void Delete(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName) + { + operations.DeleteAsync(resourceGroupName, autoscaleSettingName).GetAwaiter().GetResult(); + } + + /// + /// Deletes and autoscale setting + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, autoscaleSettingName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets an autoscale setting + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + public static AutoscaleSettingResource Get(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName) + { + return operations.GetAsync(resourceGroupName, autoscaleSettingName).GetAwaiter().GetResult(); + } + + /// + /// Gets an autoscale setting + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, autoscaleSettingName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing AutoscaleSettingsResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + public static AutoscaleSettingResource Update(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource) + { + return operations.UpdateAsync(resourceGroupName, autoscaleSettingName, autoscaleSettingResource).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing AutoscaleSettingsResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IAutoscaleSettingsOperations operations, string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The operations group for this extension method. + /// + public static IPage ListBySubscription(this IAutoscaleSettingsOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IAutoscaleSettingsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the autoscale settings for a resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IAutoscaleSettingsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the autoscale settings for a resource group + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IAutoscaleSettingsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IAutoscaleSettingsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this IAutoscaleSettingsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/BaselinesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/BaselinesOperations.cs new file mode 100644 index 000000000000..36834d87f796 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/BaselinesOperations.cs @@ -0,0 +1,310 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BaselinesOperations operations. + /// + internal partial class BaselinesOperations : IServiceOperations, IBaselinesOperations + { + /// + /// Initializes a new instance of the BaselinesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal BaselinesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// **Lists the metric baseline values for a resource**. + /// + /// + /// The identifier of the resource. + /// + /// + /// The names of the metrics (comma separated) to retrieve. Special case: If a + /// metricname itself has a comma in it then use %2 to indicate it. Eg: + /// 'Metric,Name1' should be **'Metric%2Name1'** + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// The timespan of the query. It is a string with the following format + /// 'startDateTime_ISO/endDateTime_ISO'. + /// + /// + /// The interval (i.e. timegrain) of the query. + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// + /// + /// The list of sensitivities (comma separated) to retrieve. + /// + /// + /// The **$filter** is used to reduce the set of metric data returned. Example: + /// Metric contains metadata A, B and C. - Return all time series of C where A + /// = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq 'b1' or B eq 'b2' and C + /// eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' + /// or B = 'b2'** This is invalid because the logical or operator cannot + /// separate two different metadata names. - Return all time series where A = + /// a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - + /// Return all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C + /// eq '*'**. Special case: When dimension name or dimension value uses round + /// brackets. Eg: When dimension name is **dim (test) 1** Instead of using + /// $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' + /// "** When dimension name is **dim (test) 3** and dimension value is **dim3 + /// (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) val' " + /// use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "** + /// + /// + /// Allows retrieving only metadata of the baseline. On data request all + /// information is retrieved. Possible values include: 'Data', 'Metadata' + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceUri, string metricnames = default(string), string metricnamespace = default(string), string timespan = default(string), System.TimeSpan? interval = default(System.TimeSpan?), string aggregation = default(string), string sensitivities = default(string), string filter = default(string), ResultType? resultType = default(ResultType?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + string apiVersion = "2019-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("metricnames", metricnames); + tracingParameters.Add("metricnamespace", metricnamespace); + tracingParameters.Add("timespan", timespan); + tracingParameters.Add("interval", interval); + tracingParameters.Add("aggregation", aggregation); + tracingParameters.Add("sensitivities", sensitivities); + tracingParameters.Add("filter", filter); + tracingParameters.Add("resultType", resultType); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/Microsoft.Insights/metricBaselines").ToString(); + _url = _url.Replace("{resourceUri}", resourceUri); + List _queryParameters = new List(); + if (metricnames != null) + { + _queryParameters.Add(string.Format("metricnames={0}", System.Uri.EscapeDataString(metricnames))); + } + if (metricnamespace != null) + { + _queryParameters.Add(string.Format("metricnamespace={0}", System.Uri.EscapeDataString(metricnamespace))); + } + if (timespan != null) + { + _queryParameters.Add(string.Format("timespan={0}", System.Uri.EscapeDataString(timespan))); + } + if (interval != null) + { + _queryParameters.Add(string.Format("interval={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(interval, Client.SerializationSettings).Trim('"')))); + } + if (aggregation != null) + { + _queryParameters.Add(string.Format("aggregation={0}", System.Uri.EscapeDataString(aggregation))); + } + if (sensitivities != null) + { + _queryParameters.Add(string.Format("sensitivities={0}", System.Uri.EscapeDataString(sensitivities))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (resultType != null) + { + _queryParameters.Add(string.Format("resultType={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(resultType, Client.SerializationSettings).Trim('"')))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/BaselinesOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/BaselinesOperationsExtensions.cs new file mode 100644 index 000000000000..3fa0170b488f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/BaselinesOperationsExtensions.cs @@ -0,0 +1,143 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for BaselinesOperations. + /// + public static partial class BaselinesOperationsExtensions + { + /// + /// **Lists the metric baseline values for a resource**. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The names of the metrics (comma separated) to retrieve. Special case: If a + /// metricname itself has a comma in it then use %2 to indicate it. Eg: + /// 'Metric,Name1' should be **'Metric%2Name1'** + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// The timespan of the query. It is a string with the following format + /// 'startDateTime_ISO/endDateTime_ISO'. + /// + /// + /// The interval (i.e. timegrain) of the query. + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// + /// + /// The list of sensitivities (comma separated) to retrieve. + /// + /// + /// The **$filter** is used to reduce the set of metric data returned. Example: + /// Metric contains metadata A, B and C. - Return all time series of C where A + /// = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq 'b1' or B eq 'b2' and C + /// eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' + /// or B = 'b2'** This is invalid because the logical or operator cannot + /// separate two different metadata names. - Return all time series where A = + /// a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - + /// Return all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C + /// eq '*'**. Special case: When dimension name or dimension value uses round + /// brackets. Eg: When dimension name is **dim (test) 1** Instead of using + /// $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' + /// "** When dimension name is **dim (test) 3** and dimension value is **dim3 + /// (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) val' " + /// use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "** + /// + /// + /// Allows retrieving only metadata of the baseline. On data request all + /// information is retrieved. Possible values include: 'Data', 'Metadata' + /// + public static IEnumerable List(this IBaselinesOperations operations, string resourceUri, string metricnames = default(string), string metricnamespace = default(string), string timespan = default(string), System.TimeSpan? interval = default(System.TimeSpan?), string aggregation = default(string), string sensitivities = default(string), string filter = default(string), ResultType? resultType = default(ResultType?)) + { + return operations.ListAsync(resourceUri, metricnames, metricnamespace, timespan, interval, aggregation, sensitivities, filter, resultType).GetAwaiter().GetResult(); + } + + /// + /// **Lists the metric baseline values for a resource**. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The names of the metrics (comma separated) to retrieve. Special case: If a + /// metricname itself has a comma in it then use %2 to indicate it. Eg: + /// 'Metric,Name1' should be **'Metric%2Name1'** + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// The timespan of the query. It is a string with the following format + /// 'startDateTime_ISO/endDateTime_ISO'. + /// + /// + /// The interval (i.e. timegrain) of the query. + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// + /// + /// The list of sensitivities (comma separated) to retrieve. + /// + /// + /// The **$filter** is used to reduce the set of metric data returned. Example: + /// Metric contains metadata A, B and C. - Return all time series of C where A + /// = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq 'b1' or B eq 'b2' and C + /// eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' + /// or B = 'b2'** This is invalid because the logical or operator cannot + /// separate two different metadata names. - Return all time series where A = + /// a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - + /// Return all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C + /// eq '*'**. Special case: When dimension name or dimension value uses round + /// brackets. Eg: When dimension name is **dim (test) 1** Instead of using + /// $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' + /// "** When dimension name is **dim (test) 3** and dimension value is **dim3 + /// (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) val' " + /// use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "** + /// + /// + /// Allows retrieving only metadata of the baseline. On data request all + /// information is retrieved. Possible values include: 'Data', 'Metadata' + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IBaselinesOperations operations, string resourceUri, string metricnames = default(string), string metricnamespace = default(string), string timespan = default(string), System.TimeSpan? interval = default(System.TimeSpan?), string aggregation = default(string), string sensitivities = default(string), string filter = default(string), ResultType? resultType = default(ResultType?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceUri, metricnames, metricnamespace, timespan, interval, aggregation, sensitivities, filter, resultType, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/DiagnosticSettingsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/DiagnosticSettingsOperations.cs new file mode 100644 index 000000000000..91eb2f4aa820 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/DiagnosticSettingsOperations.cs @@ -0,0 +1,774 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DiagnosticSettingsOperations operations. + /// + internal partial class DiagnosticSettingsOperations : IServiceOperations, IDiagnosticSettingsOperations + { + /// + /// Initializes a new instance of the DiagnosticSettingsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DiagnosticSettingsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Gets the active diagnostic settings for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2017-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}").ToString(); + _url = _url.Replace("{resourceUri}", resourceUri); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates diagnostic settings for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceUri, DiagnosticSettingsResource parameters, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2017-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}").ToString(); + _url = _url.Replace("{resourceUri}", resourceUri); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes existing diagnostic settings for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2017-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}").ToString(); + _url = _url.Replace("{resourceUri}", resourceUri); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the active diagnostic settings list for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string resourceUri, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + string apiVersion = "2017-05-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/Microsoft.Insights/diagnosticSettings").ToString(); + _url = _url.Replace("{resourceUri}", resourceUri); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/DiagnosticSettingsOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/DiagnosticSettingsOperationsExtensions.cs new file mode 100644 index 000000000000..b04fabda1b16 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/DiagnosticSettingsOperationsExtensions.cs @@ -0,0 +1,182 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for DiagnosticSettingsOperations. + /// + public static partial class DiagnosticSettingsOperationsExtensions + { + /// + /// Gets the active diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + public static DiagnosticSettingsResource Get(this IDiagnosticSettingsOperations operations, string resourceUri, string name) + { + return operations.GetAsync(resourceUri, name).GetAwaiter().GetResult(); + } + + /// + /// Gets the active diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDiagnosticSettingsOperations operations, string resourceUri, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceUri, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The name of the diagnostic setting. + /// + public static DiagnosticSettingsResource CreateOrUpdate(this IDiagnosticSettingsOperations operations, string resourceUri, DiagnosticSettingsResource parameters, string name) + { + return operations.CreateOrUpdateAsync(resourceUri, parameters, name).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IDiagnosticSettingsOperations operations, string resourceUri, DiagnosticSettingsResource parameters, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceUri, parameters, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes existing diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + public static void Delete(this IDiagnosticSettingsOperations operations, string resourceUri, string name) + { + operations.DeleteAsync(resourceUri, name).GetAwaiter().GetResult(); + } + + /// + /// Deletes existing diagnostic settings for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IDiagnosticSettingsOperations operations, string resourceUri, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceUri, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the active diagnostic settings list for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + public static DiagnosticSettingsResourceCollection List(this IDiagnosticSettingsOperations operations, string resourceUri) + { + return operations.ListAsync(resourceUri).GetAwaiter().GetResult(); + } + + /// + /// Gets the active diagnostic settings list for the specified resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IDiagnosticSettingsOperations operations, string resourceUri, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceUri, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/EventCategoriesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/EventCategoriesOperations.cs new file mode 100644 index 000000000000..e5b727c56c84 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/EventCategoriesOperations.cs @@ -0,0 +1,216 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EventCategoriesOperations operations. + /// + internal partial class EventCategoriesOperations : IServiceOperations, IEventCategoriesOperations + { + /// + /// Initializes a new instance of the EventCategoriesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal EventCategoriesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Get the list of available event categories supported in the Activity Logs + /// Service.<br>The current list includes the following: Administrative, + /// Security, ServiceHealth, Alert, Recommendation, Policy. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + string apiVersion = "2015-04-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Insights/eventcategories").ToString(); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/EventCategoriesOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/EventCategoriesOperationsExtensions.cs new file mode 100644 index 000000000000..f4bd0714fd98 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/EventCategoriesOperationsExtensions.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for EventCategoriesOperations. + /// + public static partial class EventCategoriesOperationsExtensions + { + /// + /// Get the list of available event categories supported in the Activity Logs + /// Service.<br>The current list includes the following: Administrative, + /// Security, ServiceHealth, Alert, Recommendation, Policy. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable List(this IEventCategoriesOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Get the list of available event categories supported in the Activity Logs + /// Service.<br>The current list includes the following: Administrative, + /// Security, ServiceHealth, Alert, Recommendation, Policy. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IEventCategoriesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IActivityLogsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IActivityLogsOperations.cs new file mode 100644 index 000000000000..79a99a34891e --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IActivityLogsOperations.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ActivityLogsOperations operations. + /// + public partial interface IActivityLogsOperations + { + /// + /// Provides the list of records from the activity logs. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// Used to fetch events with only the given properties.<br>The + /// **$select** argument is a comma separated list of property names to + /// be returned. Possible values are: *authorization*, *claims*, + /// *correlationId*, *description*, *eventDataId*, *eventName*, + /// *eventTimestamp*, *httpRequest*, *level*, *operationId*, + /// *operationName*, *properties*, *resourceGroupName*, + /// *resourceProviderName*, *resourceId*, *status*, + /// *submissionTimestamp*, *subStatus*, *subscriptionId* + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(ODataQuery odataQuery, string select = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Provides the list of records from the activity logs. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IAlertRulesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IAlertRulesOperations.cs new file mode 100644 index 000000000000..8cb6ba8bf33c --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IAlertRulesOperations.cs @@ -0,0 +1,172 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AlertRulesOperations operations. + /// + public partial interface IAlertRulesOperations + { + /// + /// Creates or updates a classic metric alert rule. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, AlertRuleResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a classic metric alert rule + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a classic metric alert rule + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing classic metric AlertRuleResource. To update + /// other fields use the CreateOrUpdate method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, AlertRuleResourcePatch alertRulesResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the classic metric alert rules within a resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the classic metric alert rules within a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IAutoscaleSettingsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IAutoscaleSettingsOperations.cs new file mode 100644 index 000000000000..1b889a958070 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IAutoscaleSettingsOperations.cs @@ -0,0 +1,216 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// AutoscaleSettingsOperations operations. + /// + public partial interface IAutoscaleSettingsOperations + { + /// + /// Lists the autoscale settings for a resource group + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates an autoscale setting. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes and autoscale setting + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets an autoscale setting + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing AutoscaleSettingsResource. To update other + /// fields use the CreateOrUpdate method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The autoscale setting name. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string autoscaleSettingName, AutoscaleSettingResourcePatch autoscaleSettingResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the autoscale settings for a resource group + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the autoscale settings for a subscription + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IBaselinesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IBaselinesOperations.cs new file mode 100644 index 000000000000..5a76f0c09ee8 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IBaselinesOperations.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// BaselinesOperations operations. + /// + public partial interface IBaselinesOperations + { + /// + /// **Lists the metric baseline values for a resource**. + /// + /// + /// The identifier of the resource. + /// + /// + /// The names of the metrics (comma separated) to retrieve. Special + /// case: If a metricname itself has a comma in it then use %2 to + /// indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'** + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// The timespan of the query. It is a string with the following format + /// 'startDateTime_ISO/endDateTime_ISO'. + /// + /// + /// The interval (i.e. timegrain) of the query. + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// + /// + /// The list of sensitivities (comma separated) to retrieve. + /// + /// + /// The **$filter** is used to reduce the set of metric data returned. + /// Example: Metric contains metadata A, B and C. - Return all time + /// series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B + /// eq 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A + /// eq 'a1' and B eq 'b1' and C eq '*' or B = 'b2'** This is invalid + /// because the logical or operator cannot separate two different + /// metadata names. - Return all time series where A = a1, B = b1 and C + /// = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - Return + /// all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C + /// eq '*'**. Special case: When dimension name or dimension value uses + /// round brackets. Eg: When dimension name is **dim (test) 1** Instead + /// of using $filter= "dim (test) 1 eq '*' " use **$filter= "dim + /// %2528test%2529 1 eq '*' "** When dimension name is **dim (test) 3** + /// and dimension value is **dim3 (test) val** Instead of using + /// $filter= "dim (test) 3 eq 'dim3 (test) val' " use **$filter= "dim + /// %2528test%2529 3 eq 'dim3 %2528test%2529 val' "** + /// + /// + /// Allows retrieving only metadata of the baseline. On data request + /// all information is retrieved. Possible values include: 'Data', + /// 'Metadata' + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceUri, string metricnames = default(string), string metricnamespace = default(string), string timespan = default(string), System.TimeSpan? interval = default(System.TimeSpan?), string aggregation = default(string), string sensitivities = default(string), string filter = default(string), ResultType? resultType = default(ResultType?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IDiagnosticSettingsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IDiagnosticSettingsOperations.cs new file mode 100644 index 000000000000..ed683fb71e30 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IDiagnosticSettingsOperations.cs @@ -0,0 +1,125 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// DiagnosticSettingsOperations operations. + /// + public partial interface IDiagnosticSettingsOperations + { + /// + /// Gets the active diagnostic settings for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates diagnostic settings for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceUri, DiagnosticSettingsResource parameters, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes existing diagnostic settings for the specified resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The name of the diagnostic setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceUri, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the active diagnostic settings list for the specified + /// resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string resourceUri, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IEventCategoriesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IEventCategoriesOperations.cs new file mode 100644 index 000000000000..80737e5455ef --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IEventCategoriesOperations.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EventCategoriesOperations operations. + /// + public partial interface IEventCategoriesOperations + { + /// + /// Get the list of available event categories supported in the + /// Activity Logs Service.<br>The current list includes the + /// following: Administrative, Security, ServiceHealth, Alert, + /// Recommendation, Policy. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/ILogProfilesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/ILogProfilesOperations.cs new file mode 100644 index 000000000000..f9d0fa23a80d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/ILogProfilesOperations.cs @@ -0,0 +1,138 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LogProfilesOperations operations. + /// + public partial interface ILogProfilesOperations + { + /// + /// Deletes the log profile. + /// + /// + /// The name of the log profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string logProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the log profile. + /// + /// + /// The name of the log profile. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string logProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a log profile in Azure Monitoring REST API. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string logProfileName, LogProfileResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing LogProfilesResource. To update other fields use + /// the CreateOrUpdate method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string logProfileName, LogProfileResourcePatch logProfilesResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List the log profiles. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IMetricAlertsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricAlertsOperations.cs new file mode 100644 index 000000000000..9e357c1520d3 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricAlertsOperations.cs @@ -0,0 +1,171 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricAlertsOperations operations. + /// + public partial interface IMetricAlertsOperations + { + /// + /// Retrieve alert rule definitions in a subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve alert rule definitions in a resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve an alert rule definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an metric alert definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, MetricAlertResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an metric alert definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to update. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an alert rule definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IMetricAlertsStatusOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricAlertsStatusOperations.cs new file mode 100644 index 000000000000..3974fcf5e51e --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricAlertsStatusOperations.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricAlertsStatusOperations operations. + /// + public partial interface IMetricAlertsStatusOperations + { + /// + /// Retrieve an alert rule status. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieve an alert rule status. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The name of the status. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListByNameWithHttpMessagesAsync(string resourceGroupName, string ruleName, string statusName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IMetricDefinitionsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricDefinitionsOperations.cs new file mode 100644 index 000000000000..13beb545e854 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricDefinitionsOperations.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricDefinitionsOperations operations. + /// + public partial interface IMetricDefinitionsOperations + { + /// + /// Lists the metric definitions for the resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceUri, string metricnamespace = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IMetricNamespacesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricNamespacesOperations.cs new file mode 100644 index 000000000000..79fbc8945262 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricNamespacesOperations.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricNamespacesOperations operations. + /// + public partial interface IMetricNamespacesOperations + { + /// + /// Lists the metric namespaces for the resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The ISO 8601 conform Date start time from which to query for metric + /// namespaces. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string resourceUri, string startTime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IMetricsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricsOperations.cs new file mode 100644 index 000000000000..26e01b9e62b2 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IMetricsOperations.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricsOperations operations. + /// + public partial interface IMetricsOperations + { + /// + /// **Lists the metric values for a resource**. + /// + /// + /// The identifier of the resource. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The timespan of the query. It is a string with the following format + /// 'startDateTime_ISO/endDateTime_ISO'. + /// + /// + /// The interval (i.e. timegrain) of the query. + /// + /// + /// The names of the metrics (comma separated) to retrieve. Special + /// case: If a metricname itself has a comma in it then use %2 to + /// indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'** + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// + /// + /// The maximum number of records to retrieve. + /// Valid only if $filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the + /// sort. + /// Only one order can be specified. + /// Examples: sum asc. + /// + /// + /// Reduces the set of data collected. The syntax allowed depends on + /// the operation. See the operation's description for details. + /// Possible values include: 'Data', 'Metadata' + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string resourceUri, ODataQuery odataQuery = default(ODataQuery), string timespan = default(string), System.TimeSpan? interval = default(System.TimeSpan?), string metricnames = default(string), string aggregation = default(string), int? top = default(int?), string orderby = default(string), ResultType? resultType = default(ResultType?), string metricnamespace = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IMonitorManagementClient.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IMonitorManagementClient.cs new file mode 100644 index 000000000000..e41d54c62d81 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IMonitorManagementClient.cs @@ -0,0 +1,153 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Monitor Management Client + /// + public partial interface IMonitorManagementClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// The ID of the target subscription. + /// + string SubscriptionId { get; set; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IAutoscaleSettingsOperations. + /// + IAutoscaleSettingsOperations AutoscaleSettings { get; } + + /// + /// Gets the IAlertRulesOperations. + /// + IAlertRulesOperations AlertRules { get; } + + /// + /// Gets the ILogProfilesOperations. + /// + ILogProfilesOperations LogProfiles { get; } + + /// + /// Gets the IDiagnosticSettingsOperations. + /// + IDiagnosticSettingsOperations DiagnosticSettings { get; } + + /// + /// Gets the IActivityLogsOperations. + /// + IActivityLogsOperations ActivityLogs { get; } + + /// + /// Gets the IEventCategoriesOperations. + /// + IEventCategoriesOperations EventCategories { get; } + + /// + /// Gets the IMetricDefinitionsOperations. + /// + IMetricDefinitionsOperations MetricDefinitions { get; } + + /// + /// Gets the IMetricsOperations. + /// + IMetricsOperations Metrics { get; } + + /// + /// Gets the IBaselinesOperations. + /// + IBaselinesOperations Baselines { get; } + + /// + /// Gets the IMetricAlertsOperations. + /// + IMetricAlertsOperations MetricAlerts { get; } + + /// + /// Gets the IMetricAlertsStatusOperations. + /// + IMetricAlertsStatusOperations MetricAlertsStatus { get; } + + /// + /// Gets the IMetricNamespacesOperations. + /// + IMetricNamespacesOperations MetricNamespaces { get; } + + /// + /// Gets the IPrivateLinkScopesOperations. + /// + IPrivateLinkScopesOperations PrivateLinkScopes { get; } + + /// + /// Gets the IPrivateLinkScopeOperationStatusOperations. + /// + IPrivateLinkScopeOperationStatusOperations PrivateLinkScopeOperationStatus { get; } + + /// + /// Gets the IPrivateLinkResourcesOperations. + /// + IPrivateLinkResourcesOperations PrivateLinkResources { get; } + + /// + /// Gets the IPrivateEndpointConnectionsOperations. + /// + IPrivateEndpointConnectionsOperations PrivateEndpointConnections { get; } + + /// + /// Gets the IPrivateLinkScopedResourcesOperations. + /// + IPrivateLinkScopedResourcesOperations PrivateLinkScopedResources { get; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateEndpointConnectionsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateEndpointConnectionsOperations.cs new file mode 100644 index 000000000000..8c1c483472ce --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateEndpointConnectionsOperations.cs @@ -0,0 +1,212 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnectionsOperations operations. + /// + public partial interface IPrivateEndpointConnectionsOperations + { + /// + /// Gets a private endpoint connection. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByPrivateLinkScopeWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByPrivateLinkScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkResourcesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkResourcesOperations.cs new file mode 100644 index 000000000000..75f9697b3ae9 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkResourcesOperations.cs @@ -0,0 +1,105 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResourcesOperations operations. + /// + public partial interface IPrivateLinkResourcesOperations + { + /// + /// Gets the private link resources that need to be created for a Azure + /// Monitor PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByPrivateLinkScopeWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the private link resources that need to be created for a Azure + /// Monitor PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private link resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string scopeName, string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the private link resources that need to be created for a Azure + /// Monitor PrivateLinkScope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByPrivateLinkScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopeOperationStatusOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopeOperationStatusOperations.cs new file mode 100644 index 000000000000..572210155e68 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopeOperationStatusOperations.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkScopeOperationStatusOperations operations. + /// + public partial interface IPrivateLinkScopeOperationStatusOperations + { + /// + /// Get the status of an azure asynchronous operation associated with a + /// private link scope operation. + /// + /// + /// The operation Id. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string asyncOperationId, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopedResourcesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopedResourcesOperations.cs new file mode 100644 index 000000000000..9d78062ea7b6 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopedResourcesOperations.cs @@ -0,0 +1,214 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkScopedResourcesOperations operations. + /// + public partial interface IPrivateLinkScopedResourcesOperations + { + /// + /// Gets a scoped resource in a private link scope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The resource id of the scoped Azure monitor resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, string linkedResourceId = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByPrivateLinkScopeWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The resource id of the scoped Azure monitor resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, string linkedResourceId = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByPrivateLinkScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopesOperations.cs new file mode 100644 index 000000000000..35aa285c547f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/IPrivateLinkScopesOperations.cs @@ -0,0 +1,245 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkScopesOperations operations. + /// + public partial interface IPrivateLinkScopesOperations + { + /// + /// Gets a list of all Azure Monitor PrivateLinkScopes within a + /// subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of Azure Monitor PrivateLinkScopes within a resource + /// group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a Azure Monitor PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Returns a Azure Monitor PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You + /// cannot specify a different value for InstrumentationKey nor AppId + /// in the Put operation. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Properties that need to be specified to create or update a Azure + /// Monitor PrivateLinkScope. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, AzureMonitorPrivateLinkScope azureMonitorPrivateLinkScopePayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates an existing PrivateLinkScope's tags. To update other fields + /// use the CreateOrUpdate method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Resource tags + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateTagsWithHttpMessagesAsync(string resourceGroupName, string scopeName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a Azure Monitor PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of all Azure Monitor PrivateLinkScopes within a + /// subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a list of Azure Monitor PrivateLinkScopes within a resource + /// group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/LogProfilesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/LogProfilesOperations.cs new file mode 100644 index 000000000000..a4dab2af3eb2 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/LogProfilesOperations.cs @@ -0,0 +1,1007 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LogProfilesOperations operations. + /// + internal partial class LogProfilesOperations : IServiceOperations, ILogProfilesOperations + { + /// + /// Initializes a new instance of the LogProfilesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LogProfilesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Deletes the log profile. + /// + /// + /// The name of the log profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string logProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (logProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "logProfileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("logProfileName", logProfileName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}").ToString(); + _url = _url.Replace("{logProfileName}", System.Uri.EscapeDataString(logProfileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the log profile. + /// + /// + /// The name of the log profile. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string logProfileName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (logProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "logProfileName"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("logProfileName", logProfileName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}").ToString(); + _url = _url.Replace("{logProfileName}", System.Uri.EscapeDataString(logProfileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update a log profile in Azure Monitoring REST API. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string logProfileName, LogProfileResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (logProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "logProfileName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("logProfileName", logProfileName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}").ToString(); + _url = _url.Replace("{logProfileName}", System.Uri.EscapeDataString(logProfileName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing LogProfilesResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string logProfileName, LogProfileResourcePatch logProfilesResource, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (logProfileName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "logProfileName"); + } + if (logProfilesResource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "logProfilesResource"); + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("logProfileName", logProfileName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("logProfilesResource", logProfilesResource); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{logProfileName}", System.Uri.EscapeDataString(logProfileName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(logProfilesResource != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(logProfilesResource, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List the log profiles. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2016-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/LogProfilesOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/LogProfilesOperationsExtensions.cs new file mode 100644 index 000000000000..90792ce0a5f1 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/LogProfilesOperationsExtensions.cs @@ -0,0 +1,202 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LogProfilesOperations. + /// + public static partial class LogProfilesOperationsExtensions + { + /// + /// Deletes the log profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + public static void Delete(this ILogProfilesOperations operations, string logProfileName) + { + operations.DeleteAsync(logProfileName).GetAwaiter().GetResult(); + } + + /// + /// Deletes the log profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ILogProfilesOperations operations, string logProfileName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(logProfileName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets the log profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + public static LogProfileResource Get(this ILogProfilesOperations operations, string logProfileName) + { + return operations.GetAsync(logProfileName).GetAwaiter().GetResult(); + } + + /// + /// Gets the log profile. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ILogProfilesOperations operations, string logProfileName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(logProfileName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a log profile in Azure Monitoring REST API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + public static LogProfileResource CreateOrUpdate(this ILogProfilesOperations operations, string logProfileName, LogProfileResource parameters) + { + return operations.CreateOrUpdateAsync(logProfileName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update a log profile in Azure Monitoring REST API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ILogProfilesOperations operations, string logProfileName, LogProfileResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(logProfileName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing LogProfilesResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + public static LogProfileResource Update(this ILogProfilesOperations operations, string logProfileName, LogProfileResourcePatch logProfilesResource) + { + return operations.UpdateAsync(logProfileName, logProfilesResource).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing LogProfilesResource. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the log profile. + /// + /// + /// Parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ILogProfilesOperations operations, string logProfileName, LogProfileResourcePatch logProfilesResource, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(logProfileName, logProfilesResource, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List the log profiles. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable List(this ILogProfilesOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List the log profiles. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ILogProfilesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsOperations.cs new file mode 100644 index 000000000000..8cfc97286074 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsOperations.cs @@ -0,0 +1,1269 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricAlertsOperations operations. + /// + internal partial class MetricAlertsOperations : IServiceOperations, IMetricAlertsOperations + { + /// + /// Initializes a new instance of the MetricAlertsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MetricAlertsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Retrieve alert rule definitions in a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListBySubscriptionWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2018-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve alert rule definitions in a resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + string apiVersion = "2018-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve an alert rule definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2018-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an metric alert definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, MetricAlertResource parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2018-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update an metric alert definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to update. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + string apiVersion = "2018-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete an alert rule definition. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2018-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsOperationsExtensions.cs new file mode 100644 index 000000000000..7784b60e9ce0 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsOperationsExtensions.cs @@ -0,0 +1,258 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MetricAlertsOperations. + /// + public static partial class MetricAlertsOperationsExtensions + { + /// + /// Retrieve alert rule definitions in a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable ListBySubscription(this IMetricAlertsOperations operations) + { + return operations.ListBySubscriptionAsync().GetAwaiter().GetResult(); + } + + /// + /// Retrieve alert rule definitions in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IMetricAlertsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve alert rule definitions in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + public static IEnumerable ListByResourceGroup(this IMetricAlertsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve alert rule definitions in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IMetricAlertsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve an alert rule definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + public static MetricAlertResource Get(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName) + { + return operations.GetAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve an alert rule definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an metric alert definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + public static MetricAlertResource CreateOrUpdate(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, MetricAlertResource parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, ruleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Create or update an metric alert definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to create or update. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, MetricAlertResource parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, ruleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update an metric alert definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to update. + /// + public static MetricAlertResource Update(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters) + { + return operations.UpdateAsync(resourceGroupName, ruleName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Update an metric alert definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The parameters of the rule to update. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, MetricAlertResourcePatch parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, ruleName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an alert rule definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + public static void Delete(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName) + { + operations.DeleteAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Delete an alert rule definition. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IMetricAlertsOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsStatusOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsStatusOperations.cs new file mode 100644 index 000000000000..5f1a9a47b786 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsStatusOperations.cs @@ -0,0 +1,477 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricAlertsStatusOperations operations. + /// + internal partial class MetricAlertsStatusOperations : IServiceOperations, IMetricAlertsStatusOperations + { + /// + /// Initializes a new instance of the MetricAlertsStatusOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MetricAlertsStatusOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string resourceGroupName, string ruleName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + string apiVersion = "2018-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The name of the status. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListByNameWithHttpMessagesAsync(string resourceGroupName, string ruleName, string statusName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (ruleName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ruleName"); + } + if (statusName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "statusName"); + } + string apiVersion = "2018-03-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("ruleName", ruleName); + tracingParameters.Add("statusName", statusName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByName", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{ruleName}", System.Uri.EscapeDataString(ruleName)); + _url = _url.Replace("{statusName}", System.Uri.EscapeDataString(statusName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsStatusOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsStatusOperationsExtensions.cs new file mode 100644 index 000000000000..e5a74a13dd15 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricAlertsStatusOperationsExtensions.cs @@ -0,0 +1,111 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MetricAlertsStatusOperations. + /// + public static partial class MetricAlertsStatusOperationsExtensions + { + /// + /// Retrieve an alert rule status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + public static MetricAlertStatusCollection List(this IMetricAlertsStatusOperations operations, string resourceGroupName, string ruleName) + { + return operations.ListAsync(resourceGroupName, ruleName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IMetricAlertsStatusOperations operations, string resourceGroupName, string ruleName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, ruleName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The name of the status. + /// + public static MetricAlertStatusCollection ListByName(this IMetricAlertsStatusOperations operations, string resourceGroupName, string ruleName, string statusName) + { + return operations.ListByNameAsync(resourceGroupName, ruleName, statusName).GetAwaiter().GetResult(); + } + + /// + /// Retrieve an alert rule status. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the rule. + /// + /// + /// The name of the status. + /// + /// + /// The cancellation token. + /// + public static async Task ListByNameAsync(this IMetricAlertsStatusOperations operations, string resourceGroupName, string ruleName, string statusName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByNameWithHttpMessagesAsync(resourceGroupName, ruleName, statusName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricDefinitionsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricDefinitionsOperations.cs new file mode 100644 index 000000000000..7e78831dfd41 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricDefinitionsOperations.cs @@ -0,0 +1,237 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricDefinitionsOperations operations. + /// + internal partial class MetricDefinitionsOperations : IServiceOperations, IMetricDefinitionsOperations + { + /// + /// Initializes a new instance of the MetricDefinitionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MetricDefinitionsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Lists the metric definitions for the resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceUri, string metricnamespace = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + string apiVersion = "2018-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("metricnamespace", metricnamespace); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/Microsoft.Insights/metricDefinitions").ToString(); + _url = _url.Replace("{resourceUri}", resourceUri); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (metricnamespace != null) + { + _queryParameters.Add(string.Format("metricnamespace={0}", System.Uri.EscapeDataString(metricnamespace))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricDefinitionsOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricDefinitionsOperationsExtensions.cs new file mode 100644 index 000000000000..b7a408b6ca33 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricDefinitionsOperationsExtensions.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MetricDefinitionsOperations. + /// + public static partial class MetricDefinitionsOperationsExtensions + { + /// + /// Lists the metric definitions for the resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Metric namespace to query metric definitions for. + /// + public static IEnumerable List(this IMetricDefinitionsOperations operations, string resourceUri, string metricnamespace = default(string)) + { + return operations.ListAsync(resourceUri, metricnamespace).GetAwaiter().GetResult(); + } + + /// + /// Lists the metric definitions for the resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IMetricDefinitionsOperations operations, string resourceUri, string metricnamespace = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceUri, metricnamespace, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricNamespacesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricNamespacesOperations.cs new file mode 100644 index 000000000000..8e73a78d2a25 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricNamespacesOperations.cs @@ -0,0 +1,238 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricNamespacesOperations operations. + /// + internal partial class MetricNamespacesOperations : IServiceOperations, IMetricNamespacesOperations + { + /// + /// Initializes a new instance of the MetricNamespacesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MetricNamespacesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Lists the metric namespaces for the resource. + /// + /// + /// The identifier of the resource. + /// + /// + /// The ISO 8601 conform Date start time from which to query for metric + /// namespaces. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceUri, string startTime = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + string apiVersion = "2017-12-01-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("startTime", startTime); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/microsoft.insights/metricNamespaces").ToString(); + _url = _url.Replace("{resourceUri}", resourceUri); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (startTime != null) + { + _queryParameters.Add(string.Format("startTime={0}", System.Uri.EscapeDataString(startTime))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricNamespacesOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricNamespacesOperationsExtensions.cs new file mode 100644 index 000000000000..bf67203b2baf --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricNamespacesOperationsExtensions.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MetricNamespacesOperations. + /// + public static partial class MetricNamespacesOperationsExtensions + { + /// + /// Lists the metric namespaces for the resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The ISO 8601 conform Date start time from which to query for metric + /// namespaces. + /// + public static IEnumerable List(this IMetricNamespacesOperations operations, string resourceUri, string startTime = default(string)) + { + return operations.ListAsync(resourceUri, startTime).GetAwaiter().GetResult(); + } + + /// + /// Lists the metric namespaces for the resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// The ISO 8601 conform Date start time from which to query for metric + /// namespaces. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IMetricNamespacesOperations operations, string resourceUri, string startTime = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceUri, startTime, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricsOperations.cs new file mode 100644 index 000000000000..d7369c8dbb9f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricsOperations.cs @@ -0,0 +1,315 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MetricsOperations operations. + /// + internal partial class MetricsOperations : IServiceOperations, IMetricsOperations + { + /// + /// Initializes a new instance of the MetricsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MetricsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// **Lists the metric values for a resource**. + /// + /// + /// The identifier of the resource. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The timespan of the query. It is a string with the following format + /// 'startDateTime_ISO/endDateTime_ISO'. + /// + /// + /// The interval (i.e. timegrain) of the query. + /// + /// + /// The names of the metrics (comma separated) to retrieve. Special case: If a + /// metricname itself has a comma in it then use %2 to indicate it. Eg: + /// 'Metric,Name1' should be **'Metric%2Name1'** + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// + /// + /// The maximum number of records to retrieve. + /// Valid only if $filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// Examples: sum asc. + /// + /// + /// Reduces the set of data collected. The syntax allowed depends on the + /// operation. See the operation's description for details. Possible values + /// include: 'Data', 'Metadata' + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string resourceUri, ODataQuery odataQuery = default(ODataQuery), string timespan = default(string), System.TimeSpan? interval = default(System.TimeSpan?), string metricnames = default(string), string aggregation = default(string), int? top = default(int?), string orderby = default(string), ResultType? resultType = default(ResultType?), string metricnamespace = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceUri"); + } + string apiVersion = "2018-01-01"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("resourceUri", resourceUri); + tracingParameters.Add("timespan", timespan); + tracingParameters.Add("interval", interval); + tracingParameters.Add("metricnames", metricnames); + tracingParameters.Add("aggregation", aggregation); + tracingParameters.Add("top", top); + tracingParameters.Add("orderby", orderby); + tracingParameters.Add("resultType", resultType); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("metricnamespace", metricnamespace); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{resourceUri}/providers/Microsoft.Insights/metrics").ToString(); + _url = _url.Replace("{resourceUri}", resourceUri); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + if (timespan != null) + { + _queryParameters.Add(string.Format("timespan={0}", System.Uri.EscapeDataString(timespan))); + } + if (interval != null) + { + _queryParameters.Add(string.Format("interval={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(interval, Client.SerializationSettings).Trim('"')))); + } + if (metricnames != null) + { + _queryParameters.Add(string.Format("metricnames={0}", System.Uri.EscapeDataString(metricnames))); + } + if (aggregation != null) + { + _queryParameters.Add(string.Format("aggregation={0}", System.Uri.EscapeDataString(aggregation))); + } + if (top != null) + { + _queryParameters.Add(string.Format("top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (orderby != null) + { + _queryParameters.Add(string.Format("orderby={0}", System.Uri.EscapeDataString(orderby))); + } + if (resultType != null) + { + _queryParameters.Add(string.Format("resultType={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(resultType, Client.SerializationSettings).Trim('"')))); + } + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (metricnamespace != null) + { + _queryParameters.Add(string.Format("metricnamespace={0}", System.Uri.EscapeDataString(metricnamespace))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MetricsOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MetricsOperationsExtensions.cs new file mode 100644 index 000000000000..3be2a5704802 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MetricsOperationsExtensions.cs @@ -0,0 +1,132 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MetricsOperations. + /// + public static partial class MetricsOperationsExtensions + { + /// + /// **Lists the metric values for a resource**. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The timespan of the query. It is a string with the following format + /// 'startDateTime_ISO/endDateTime_ISO'. + /// + /// + /// The interval (i.e. timegrain) of the query. + /// + /// + /// The names of the metrics (comma separated) to retrieve. Special case: If a + /// metricname itself has a comma in it then use %2 to indicate it. Eg: + /// 'Metric,Name1' should be **'Metric%2Name1'** + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// + /// + /// The maximum number of records to retrieve. + /// Valid only if $filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// Examples: sum asc. + /// + /// + /// Reduces the set of data collected. The syntax allowed depends on the + /// operation. See the operation's description for details. Possible values + /// include: 'Data', 'Metadata' + /// + /// + /// Metric namespace to query metric definitions for. + /// + public static Response List(this IMetricsOperations operations, string resourceUri, ODataQuery odataQuery = default(ODataQuery), string timespan = default(string), System.TimeSpan? interval = default(System.TimeSpan?), string metricnames = default(string), string aggregation = default(string), int? top = default(int?), string orderby = default(string), ResultType? resultType = default(ResultType?), string metricnamespace = default(string)) + { + return operations.ListAsync(resourceUri, odataQuery, timespan, interval, metricnames, aggregation, top, orderby, resultType, metricnamespace).GetAwaiter().GetResult(); + } + + /// + /// **Lists the metric values for a resource**. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The timespan of the query. It is a string with the following format + /// 'startDateTime_ISO/endDateTime_ISO'. + /// + /// + /// The interval (i.e. timegrain) of the query. + /// + /// + /// The names of the metrics (comma separated) to retrieve. Special case: If a + /// metricname itself has a comma in it then use %2 to indicate it. Eg: + /// 'Metric,Name1' should be **'Metric%2Name1'** + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// + /// + /// The maximum number of records to retrieve. + /// Valid only if $filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// Examples: sum asc. + /// + /// + /// Reduces the set of data collected. The syntax allowed depends on the + /// operation. See the operation's description for details. Possible values + /// include: 'Data', 'Metadata' + /// + /// + /// Metric namespace to query metric definitions for. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IMetricsOperations operations, string resourceUri, ODataQuery odataQuery = default(ODataQuery), string timespan = default(string), System.TimeSpan? interval = default(System.TimeSpan?), string metricnames = default(string), string aggregation = default(string), int? top = default(int?), string orderby = default(string), ResultType? resultType = default(ResultType?), string metricnamespace = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceUri, odataQuery, timespan, interval, metricnames, aggregation, top, orderby, resultType, metricnamespace, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AggregationType.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AggregationType.cs new file mode 100644 index 000000000000..fed1698e35fb --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AggregationType.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for AggregationType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum AggregationType + { + [EnumMember(Value = "None")] + None, + [EnumMember(Value = "Average")] + Average, + [EnumMember(Value = "Count")] + Count, + [EnumMember(Value = "Minimum")] + Minimum, + [EnumMember(Value = "Maximum")] + Maximum, + [EnumMember(Value = "Total")] + Total + } + internal static class AggregationTypeEnumExtension + { + internal static string ToSerializedValue(this AggregationType? value) + { + return value == null ? null : ((AggregationType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this AggregationType value) + { + switch( value ) + { + case AggregationType.None: + return "None"; + case AggregationType.Average: + return "Average"; + case AggregationType.Count: + return "Count"; + case AggregationType.Minimum: + return "Minimum"; + case AggregationType.Maximum: + return "Maximum"; + case AggregationType.Total: + return "Total"; + } + return null; + } + + internal static AggregationType? ParseAggregationType(this string value) + { + switch( value ) + { + case "None": + return AggregationType.None; + case "Average": + return AggregationType.Average; + case "Count": + return AggregationType.Count; + case "Minimum": + return AggregationType.Minimum; + case "Maximum": + return AggregationType.Maximum; + case "Total": + return AggregationType.Total; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AggregationTypeEnum.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AggregationTypeEnum.cs new file mode 100644 index 000000000000..e2007d5c8ddc --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AggregationTypeEnum.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for AggregationTypeEnum. + /// + public static class AggregationTypeEnum + { + public const string Average = "Average"; + public const string Count = "Count"; + public const string Minimum = "Minimum"; + public const string Maximum = "Maximum"; + public const string Total = "Total"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AlertRuleResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AlertRuleResource.cs new file mode 100644 index 000000000000..6c956147d4a5 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AlertRuleResource.cs @@ -0,0 +1,149 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The alert rule resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class AlertRuleResource : Resource + { + /// + /// Initializes a new instance of the AlertRuleResource class. + /// + public AlertRuleResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertRuleResource class. + /// + /// Resource location + /// the name of the alert + /// rule. + /// the flag that indicates whether the alert + /// rule is enabled. + /// the condition that results in the alert + /// rule being activated. + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// the description of the alert rule that + /// will be included in the alert email. + /// the provisioning state. + /// action that is performed when the alert rule + /// becomes active, and when an alert condition is resolved. + /// the array of actions that are performed when + /// the alert rule becomes active, and when an alert condition is + /// resolved. + /// Last time the rule was updated in + /// ISO8601 format. + public AlertRuleResource(string location, string alertRuleResourceName, bool isEnabled, RuleCondition condition, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string description = default(string), string provisioningState = default(string), RuleAction action = default(RuleAction), IList actions = default(IList), System.DateTime? lastUpdatedTime = default(System.DateTime?)) + : base(location, id, name, type, tags) + { + AlertRuleResourceName = alertRuleResourceName; + Description = description; + ProvisioningState = provisioningState; + IsEnabled = isEnabled; + Condition = condition; + Action = action; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the alert rule. + /// + [JsonProperty(PropertyName = "properties.name")] + public string AlertRuleResourceName { get; set; } + + /// + /// Gets or sets the description of the alert rule that will be + /// included in the alert email. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the flag that indicates whether the alert rule is + /// enabled. + /// + [JsonProperty(PropertyName = "properties.isEnabled")] + public bool IsEnabled { get; set; } + + /// + /// Gets or sets the condition that results in the alert rule being + /// activated. + /// + [JsonProperty(PropertyName = "properties.condition")] + public RuleCondition Condition { get; set; } + + /// + /// Gets or sets action that is performed when the alert rule becomes + /// active, and when an alert condition is resolved. + /// + [JsonProperty(PropertyName = "properties.action")] + public RuleAction Action { get; set; } + + /// + /// Gets or sets the array of actions that are performed when the alert + /// rule becomes active, and when an alert condition is resolved. + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + /// + /// Gets last time the rule was updated in ISO8601 format. + /// + [JsonProperty(PropertyName = "properties.lastUpdatedTime")] + public System.DateTime? LastUpdatedTime { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (AlertRuleResourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AlertRuleResourceName"); + } + if (Condition == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Condition"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AlertRuleResourcePatch.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AlertRuleResourcePatch.cs new file mode 100644 index 000000000000..002d92250887 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AlertRuleResourcePatch.cs @@ -0,0 +1,149 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The alert rule object for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class AlertRuleResourcePatch + { + /// + /// Initializes a new instance of the AlertRuleResourcePatch class. + /// + public AlertRuleResourcePatch() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AlertRuleResourcePatch class. + /// + /// the name of the alert rule. + /// the flag that indicates whether the alert + /// rule is enabled. + /// the condition that results in the alert + /// rule being activated. + /// Resource tags + /// the description of the alert rule that + /// will be included in the alert email. + /// the provisioning state. + /// action that is performed when the alert rule + /// becomes active, and when an alert condition is resolved. + /// the array of actions that are performed when + /// the alert rule becomes active, and when an alert condition is + /// resolved. + /// Last time the rule was updated in + /// ISO8601 format. + public AlertRuleResourcePatch(string name, bool isEnabled, RuleCondition condition, IDictionary tags = default(IDictionary), string description = default(string), string provisioningState = default(string), RuleAction action = default(RuleAction), IList actions = default(IList), System.DateTime? lastUpdatedTime = default(System.DateTime?)) + { + Tags = tags; + Name = name; + Description = description; + ProvisioningState = provisioningState; + IsEnabled = isEnabled; + Condition = condition; + Action = action; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the name of the alert rule. + /// + [JsonProperty(PropertyName = "properties.name")] + public string Name { get; set; } + + /// + /// Gets or sets the description of the alert rule that will be + /// included in the alert email. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets the provisioning state. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the flag that indicates whether the alert rule is + /// enabled. + /// + [JsonProperty(PropertyName = "properties.isEnabled")] + public bool IsEnabled { get; set; } + + /// + /// Gets or sets the condition that results in the alert rule being + /// activated. + /// + [JsonProperty(PropertyName = "properties.condition")] + public RuleCondition Condition { get; set; } + + /// + /// Gets or sets action that is performed when the alert rule becomes + /// active, and when an alert condition is resolved. + /// + [JsonProperty(PropertyName = "properties.action")] + public RuleAction Action { get; set; } + + /// + /// Gets or sets the array of actions that are performed when the alert + /// rule becomes active, and when an alert condition is resolved. + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + /// + /// Gets last time the rule was updated in ISO8601 format. + /// + [JsonProperty(PropertyName = "properties.lastUpdatedTime")] + public System.DateTime? LastUpdatedTime { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Condition == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Condition"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleNotification.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleNotification.cs new file mode 100644 index 000000000000..8ac9f845761d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleNotification.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Autoscale notification. + /// + public partial class AutoscaleNotification + { + /// + /// Initializes a new instance of the AutoscaleNotification class. + /// + public AutoscaleNotification() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AutoscaleNotification class. + /// + /// the email notification. + /// the collection of webhook + /// notifications. + public AutoscaleNotification(EmailNotification email = default(EmailNotification), IList webhooks = default(IList)) + { + Email = email; + Webhooks = webhooks; + CustomInit(); + } + /// + /// Static constructor for AutoscaleNotification class. + /// + static AutoscaleNotification() + { + Operation = "Scale"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the email notification. + /// + [JsonProperty(PropertyName = "email")] + public EmailNotification Email { get; set; } + + /// + /// Gets or sets the collection of webhook notifications. + /// + [JsonProperty(PropertyName = "webhooks")] + public IList Webhooks { get; set; } + + /// + /// the operation associated with the notification and its value must + /// be "scale" + /// + [JsonProperty(PropertyName = "operation")] + public static string Operation { get; private set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleProfile.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleProfile.cs new file mode 100644 index 000000000000..ac0e4a09c11f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleProfile.cs @@ -0,0 +1,140 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Autoscale profile. + /// + public partial class AutoscaleProfile + { + /// + /// Initializes a new instance of the AutoscaleProfile class. + /// + public AutoscaleProfile() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AutoscaleProfile class. + /// + /// the name of the profile. + /// the number of instances that can be used + /// during this profile. + /// the collection of rules that provide the + /// triggers and parameters for the scaling action. A maximum of 10 + /// rules can be specified. + /// the specific date-time for the profile. + /// This element is not used if the Recurrence element is used. + /// the repeating times at which this profile + /// begins. This element is not used if the FixedDate element is + /// used. + public AutoscaleProfile(string name, ScaleCapacity capacity, IList rules, TimeWindow fixedDate = default(TimeWindow), Recurrence recurrence = default(Recurrence)) + { + Name = name; + Capacity = capacity; + Rules = rules; + FixedDate = fixedDate; + Recurrence = recurrence; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the profile. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the number of instances that can be used during this + /// profile. + /// + [JsonProperty(PropertyName = "capacity")] + public ScaleCapacity Capacity { get; set; } + + /// + /// Gets or sets the collection of rules that provide the triggers and + /// parameters for the scaling action. A maximum of 10 rules can be + /// specified. + /// + [JsonProperty(PropertyName = "rules")] + public IList Rules { get; set; } + + /// + /// Gets or sets the specific date-time for the profile. This element + /// is not used if the Recurrence element is used. + /// + [JsonProperty(PropertyName = "fixedDate")] + public TimeWindow FixedDate { get; set; } + + /// + /// Gets or sets the repeating times at which this profile begins. This + /// element is not used if the FixedDate element is used. + /// + [JsonProperty(PropertyName = "recurrence")] + public Recurrence Recurrence { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Capacity == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Capacity"); + } + if (Rules == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Rules"); + } + if (Capacity != null) + { + Capacity.Validate(); + } + if (Rules != null) + { + foreach (var element in Rules) + { + if (element != null) + { + element.Validate(); + } + } + } + if (FixedDate != null) + { + FixedDate.Validate(); + } + if (Recurrence != null) + { + Recurrence.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleSettingResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleSettingResource.cs new file mode 100644 index 000000000000..d888e469a939 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleSettingResource.cs @@ -0,0 +1,143 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The autoscale setting resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class AutoscaleSettingResource : Resource + { + /// + /// Initializes a new instance of the AutoscaleSettingResource class. + /// + public AutoscaleSettingResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AutoscaleSettingResource class. + /// + /// Resource location + /// the collection of automatic scaling profiles + /// that specify different scaling parameters for different time + /// periods. A maximum of 20 profiles can be specified. + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// the collection of + /// notifications. + /// the enabled flag. Specifies whether automatic + /// scaling is enabled for the resource. The default value is + /// 'true'. + /// the name of the + /// autoscale setting. + /// the resource identifier of the + /// resource that the autoscale setting should be added to. + /// the location of the resource + /// that the autoscale setting should be added to. + public AutoscaleSettingResource(string location, IList profiles, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList notifications = default(IList), bool? enabled = default(bool?), string autoscaleSettingResourceName = default(string), string targetResourceUri = default(string), string targetResourceLocation = default(string)) + : base(location, id, name, type, tags) + { + Profiles = profiles; + Notifications = notifications; + Enabled = enabled; + AutoscaleSettingResourceName = autoscaleSettingResourceName; + TargetResourceUri = targetResourceUri; + TargetResourceLocation = targetResourceLocation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the collection of automatic scaling profiles that + /// specify different scaling parameters for different time periods. A + /// maximum of 20 profiles can be specified. + /// + [JsonProperty(PropertyName = "properties.profiles")] + public IList Profiles { get; set; } + + /// + /// Gets or sets the collection of notifications. + /// + [JsonProperty(PropertyName = "properties.notifications")] + public IList Notifications { get; set; } + + /// + /// Gets or sets the enabled flag. Specifies whether automatic scaling + /// is enabled for the resource. The default value is 'true'. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool? Enabled { get; set; } + + /// + /// Gets or sets the name of the autoscale setting. + /// + [JsonProperty(PropertyName = "properties.name")] + public string AutoscaleSettingResourceName { get; set; } + + /// + /// Gets or sets the resource identifier of the resource that the + /// autoscale setting should be added to. + /// + [JsonProperty(PropertyName = "properties.targetResourceUri")] + public string TargetResourceUri { get; set; } + + /// + /// Gets or sets the location of the resource that the autoscale + /// setting should be added to. + /// + [JsonProperty(PropertyName = "properties.targetResourceLocation")] + public string TargetResourceLocation { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Profiles == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Profiles"); + } + if (Profiles != null) + { + if (Profiles.Count > 20) + { + throw new ValidationException(ValidationRules.MaxItems, "Profiles", 20); + } + foreach (var element in Profiles) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleSettingResourcePatch.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleSettingResourcePatch.cs new file mode 100644 index 000000000000..c23a95232d7f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AutoscaleSettingResourcePatch.cs @@ -0,0 +1,145 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The autoscale setting object for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class AutoscaleSettingResourcePatch + { + /// + /// Initializes a new instance of the AutoscaleSettingResourcePatch + /// class. + /// + public AutoscaleSettingResourcePatch() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AutoscaleSettingResourcePatch + /// class. + /// + /// the collection of automatic scaling profiles + /// that specify different scaling parameters for different time + /// periods. A maximum of 20 profiles can be specified. + /// Resource tags + /// the collection of + /// notifications. + /// the enabled flag. Specifies whether automatic + /// scaling is enabled for the resource. The default value is + /// 'true'. + /// the name of the autoscale setting. + /// the resource identifier of the + /// resource that the autoscale setting should be added to. + /// the location of the resource + /// that the autoscale setting should be added to. + public AutoscaleSettingResourcePatch(IList profiles, IDictionary tags = default(IDictionary), IList notifications = default(IList), bool? enabled = default(bool?), string name = default(string), string targetResourceUri = default(string), string targetResourceLocation = default(string)) + { + Tags = tags; + Profiles = profiles; + Notifications = notifications; + Enabled = enabled; + Name = name; + TargetResourceUri = targetResourceUri; + TargetResourceLocation = targetResourceLocation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the collection of automatic scaling profiles that + /// specify different scaling parameters for different time periods. A + /// maximum of 20 profiles can be specified. + /// + [JsonProperty(PropertyName = "properties.profiles")] + public IList Profiles { get; set; } + + /// + /// Gets or sets the collection of notifications. + /// + [JsonProperty(PropertyName = "properties.notifications")] + public IList Notifications { get; set; } + + /// + /// Gets or sets the enabled flag. Specifies whether automatic scaling + /// is enabled for the resource. The default value is 'true'. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool? Enabled { get; set; } + + /// + /// Gets or sets the name of the autoscale setting. + /// + [JsonProperty(PropertyName = "properties.name")] + public string Name { get; set; } + + /// + /// Gets or sets the resource identifier of the resource that the + /// autoscale setting should be added to. + /// + [JsonProperty(PropertyName = "properties.targetResourceUri")] + public string TargetResourceUri { get; set; } + + /// + /// Gets or sets the location of the resource that the autoscale + /// setting should be added to. + /// + [JsonProperty(PropertyName = "properties.targetResourceLocation")] + public string TargetResourceLocation { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Profiles == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Profiles"); + } + if (Profiles != null) + { + if (Profiles.Count > 20) + { + throw new ValidationException(ValidationRules.MaxItems, "Profiles", 20); + } + foreach (var element in Profiles) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/AzureMonitorPrivateLinkScope.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AzureMonitorPrivateLinkScope.cs new file mode 100644 index 000000000000..47dbcf85231d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/AzureMonitorPrivateLinkScope.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure Monitor PrivateLinkScope definition. + /// + [Rest.Serialization.JsonTransformation] + public partial class AzureMonitorPrivateLinkScope : PrivateLinkScopesResource + { + /// + /// Initializes a new instance of the AzureMonitorPrivateLinkScope + /// class. + /// + public AzureMonitorPrivateLinkScope() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureMonitorPrivateLinkScope + /// class. + /// + /// Resource location + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// Current state of this + /// PrivateLinkScope: whether or not is has been provisioned within the + /// resource group it is defined. Users cannot change this value but + /// are able to read from it. Values will include Provisioning + /// ,Succeeded, Canceled and Failed. + /// List of private endpoint + /// connections. + public AzureMonitorPrivateLinkScope(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string provisioningState = default(string), IList privateEndpointConnections = default(IList)) + : base(location, id, name, type, tags) + { + ProvisioningState = provisioningState; + PrivateEndpointConnections = privateEndpointConnections; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets current state of this PrivateLinkScope: whether or not is has + /// been provisioned within the resource group it is defined. Users + /// cannot change this value but are able to read from it. Values will + /// include Provisioning ,Succeeded, Canceled and Failed. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets list of private endpoint connections. + /// + [JsonProperty(PropertyName = "properties.privateEndpointConnections")] + public IList PrivateEndpointConnections { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (PrivateEndpointConnections != null) + { + foreach (var element in PrivateEndpointConnections) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/BaselineMetadata.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/BaselineMetadata.cs new file mode 100644 index 000000000000..fa234fe8bac1 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/BaselineMetadata.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a baseline metadata value. + /// + public partial class BaselineMetadata + { + /// + /// Initializes a new instance of the BaselineMetadata class. + /// + public BaselineMetadata() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the BaselineMetadata class. + /// + /// Name of the baseline metadata. + /// Value of the baseline metadata. + public BaselineMetadata(string name, string value) + { + Name = name; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the baseline metadata. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets value of the baseline metadata. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/BaselineSensitivity.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/BaselineSensitivity.cs new file mode 100644 index 000000000000..4170b0895b20 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/BaselineSensitivity.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for BaselineSensitivity. + /// + public static class BaselineSensitivity + { + public const string Low = "Low"; + public const string Medium = "Medium"; + public const string High = "High"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ComparisonOperationType.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ComparisonOperationType.cs new file mode 100644 index 000000000000..7c4846aeb1f2 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ComparisonOperationType.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ComparisonOperationType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ComparisonOperationType + { + [EnumMember(Value = "Equals")] + Equals, + [EnumMember(Value = "NotEquals")] + NotEquals, + [EnumMember(Value = "GreaterThan")] + GreaterThan, + [EnumMember(Value = "GreaterThanOrEqual")] + GreaterThanOrEqual, + [EnumMember(Value = "LessThan")] + LessThan, + [EnumMember(Value = "LessThanOrEqual")] + LessThanOrEqual + } + internal static class ComparisonOperationTypeEnumExtension + { + internal static string ToSerializedValue(this ComparisonOperationType? value) + { + return value == null ? null : ((ComparisonOperationType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ComparisonOperationType value) + { + switch( value ) + { + case ComparisonOperationType.Equals: + return "Equals"; + case ComparisonOperationType.NotEquals: + return "NotEquals"; + case ComparisonOperationType.GreaterThan: + return "GreaterThan"; + case ComparisonOperationType.GreaterThanOrEqual: + return "GreaterThanOrEqual"; + case ComparisonOperationType.LessThan: + return "LessThan"; + case ComparisonOperationType.LessThanOrEqual: + return "LessThanOrEqual"; + } + return null; + } + + internal static ComparisonOperationType? ParseComparisonOperationType(this string value) + { + switch( value ) + { + case "Equals": + return ComparisonOperationType.Equals; + case "NotEquals": + return ComparisonOperationType.NotEquals; + case "GreaterThan": + return ComparisonOperationType.GreaterThan; + case "GreaterThanOrEqual": + return ComparisonOperationType.GreaterThanOrEqual; + case "LessThan": + return ComparisonOperationType.LessThan; + case "LessThanOrEqual": + return ComparisonOperationType.LessThanOrEqual; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ConditionOperator.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ConditionOperator.cs new file mode 100644 index 000000000000..7b4003f6cb1d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ConditionOperator.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ConditionOperator. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ConditionOperator + { + [EnumMember(Value = "GreaterThan")] + GreaterThan, + [EnumMember(Value = "GreaterThanOrEqual")] + GreaterThanOrEqual, + [EnumMember(Value = "LessThan")] + LessThan, + [EnumMember(Value = "LessThanOrEqual")] + LessThanOrEqual + } + internal static class ConditionOperatorEnumExtension + { + internal static string ToSerializedValue(this ConditionOperator? value) + { + return value == null ? null : ((ConditionOperator)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ConditionOperator value) + { + switch( value ) + { + case ConditionOperator.GreaterThan: + return "GreaterThan"; + case ConditionOperator.GreaterThanOrEqual: + return "GreaterThanOrEqual"; + case ConditionOperator.LessThan: + return "LessThan"; + case ConditionOperator.LessThanOrEqual: + return "LessThanOrEqual"; + } + return null; + } + + internal static ConditionOperator? ParseConditionOperator(this string value) + { + switch( value ) + { + case "GreaterThan": + return ConditionOperator.GreaterThan; + case "GreaterThanOrEqual": + return ConditionOperator.GreaterThanOrEqual; + case "LessThan": + return ConditionOperator.LessThan; + case "LessThanOrEqual": + return ConditionOperator.LessThanOrEqual; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/DiagnosticSettingsResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DiagnosticSettingsResource.cs new file mode 100644 index 000000000000..cacc1ef47e8e --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DiagnosticSettingsResource.cs @@ -0,0 +1,139 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The diagnostic setting resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class DiagnosticSettingsResource : ProxyOnlyResource + { + /// + /// Initializes a new instance of the DiagnosticSettingsResource class. + /// + public DiagnosticSettingsResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DiagnosticSettingsResource class. + /// + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// The resource ID of the storage + /// account to which you would like to send Diagnostic Logs. + /// The service bus rule Id of the + /// diagnostic setting. This is here to maintain backwards + /// compatibility. + /// The resource Id for the + /// event hub authorization rule. + /// The name of the event hub. If none is + /// specified, the default event hub will be selected. + /// The list of metric settings. + /// The list of logs settings. + /// The full ARM resource ID of the Log + /// Analytics workspace to which you would like to send Diagnostic + /// Logs. Example: + /// /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + /// A string indicating + /// whether the export to Log Analytics should use the default + /// destination type, i.e. AzureDiagnostics, or use a destination type + /// constructed as follows: <normalized service + /// identity>_<normalized category name>. Possible values are: + /// Dedicated and null (null is default.) + public DiagnosticSettingsResource(string id = default(string), string name = default(string), string type = default(string), string storageAccountId = default(string), string serviceBusRuleId = default(string), string eventHubAuthorizationRuleId = default(string), string eventHubName = default(string), IList metrics = default(IList), IList logs = default(IList), string workspaceId = default(string), string logAnalyticsDestinationType = default(string)) + : base(id, name, type) + { + StorageAccountId = storageAccountId; + ServiceBusRuleId = serviceBusRuleId; + EventHubAuthorizationRuleId = eventHubAuthorizationRuleId; + EventHubName = eventHubName; + Metrics = metrics; + Logs = logs; + WorkspaceId = workspaceId; + LogAnalyticsDestinationType = logAnalyticsDestinationType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource ID of the storage account to which you + /// would like to send Diagnostic Logs. + /// + [JsonProperty(PropertyName = "properties.storageAccountId")] + public string StorageAccountId { get; set; } + + /// + /// Gets or sets the service bus rule Id of the diagnostic setting. + /// This is here to maintain backwards compatibility. + /// + [JsonProperty(PropertyName = "properties.serviceBusRuleId")] + public string ServiceBusRuleId { get; set; } + + /// + /// Gets or sets the resource Id for the event hub authorization rule. + /// + [JsonProperty(PropertyName = "properties.eventHubAuthorizationRuleId")] + public string EventHubAuthorizationRuleId { get; set; } + + /// + /// Gets or sets the name of the event hub. If none is specified, the + /// default event hub will be selected. + /// + [JsonProperty(PropertyName = "properties.eventHubName")] + public string EventHubName { get; set; } + + /// + /// Gets or sets the list of metric settings. + /// + [JsonProperty(PropertyName = "properties.metrics")] + public IList Metrics { get; set; } + + /// + /// Gets or sets the list of logs settings. + /// + [JsonProperty(PropertyName = "properties.logs")] + public IList Logs { get; set; } + + /// + /// Gets or sets the full ARM resource ID of the Log Analytics + /// workspace to which you would like to send Diagnostic Logs. Example: + /// /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + /// + [JsonProperty(PropertyName = "properties.workspaceId")] + public string WorkspaceId { get; set; } + + /// + /// Gets or sets a string indicating whether the export to Log + /// Analytics should use the default destination type, i.e. + /// AzureDiagnostics, or use a destination type constructed as follows: + /// &lt;normalized service identity&gt;_&lt;normalized + /// category name&gt;. Possible values are: Dedicated and null + /// (null is default.) + /// + [JsonProperty(PropertyName = "properties.logAnalyticsDestinationType")] + public string LogAnalyticsDestinationType { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/DiagnosticSettingsResourceCollection.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DiagnosticSettingsResourceCollection.cs new file mode 100644 index 000000000000..2ee813f37406 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DiagnosticSettingsResourceCollection.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a collection of alert rule resources. + /// + public partial class DiagnosticSettingsResourceCollection + { + /// + /// Initializes a new instance of the + /// DiagnosticSettingsResourceCollection class. + /// + public DiagnosticSettingsResourceCollection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// DiagnosticSettingsResourceCollection class. + /// + /// The collection of diagnostic settings + /// resources;. + public DiagnosticSettingsResourceCollection(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the collection of diagnostic settings resources;. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicMetricCriteria.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicMetricCriteria.cs new file mode 100644 index 000000000000..8dad3fa1d3f0 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicMetricCriteria.cs @@ -0,0 +1,134 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Criterion for dynamic threshold. + /// + [Newtonsoft.Json.JsonObject("DynamicThresholdCriterion")] + public partial class DynamicMetricCriteria : MultiMetricCriteria + { + /// + /// Initializes a new instance of the DynamicMetricCriteria class. + /// + public DynamicMetricCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DynamicMetricCriteria class. + /// + /// Name of the criteria. + /// Name of the metric. + /// the criteria time aggregation types. + /// Possible values include: 'Average', 'Count', 'Minimum', 'Maximum', + /// 'Total' + /// The operator used to compare the + /// metric value against the threshold. Possible values include: + /// 'GreaterThan', 'LessThan', 'GreaterOrLessThan' + /// The extent of deviation required to + /// trigger an alert. This will affect how tight the threshold is to + /// the metric series pattern. Possible values include: 'Low', + /// 'Medium', 'High' + /// The minimum number of violations + /// required within the selected lookback time window required to raise + /// an alert. + /// Unmatched properties from the + /// message are deserialized this collection + /// Namespace of the metric. + /// List of dimension conditions. + /// Allows creating an alert rule on + /// a custom metric that isn't yet emitted, by causing the metric + /// validation to be skipped. + /// Use this option to set the date from + /// which to start learning the metric historical data and calculate + /// the dynamic thresholds (in ISO8601 format) + public DynamicMetricCriteria(string name, string metricName, string timeAggregation, string operatorProperty, string alertSensitivity, DynamicThresholdFailingPeriods failingPeriods, IDictionary additionalProperties = default(IDictionary), string metricNamespace = default(string), IList dimensions = default(IList), bool? skipMetricValidation = default(bool?), System.DateTime? ignoreDataBefore = default(System.DateTime?)) + : base(name, metricName, timeAggregation, additionalProperties, metricNamespace, dimensions, skipMetricValidation) + { + OperatorProperty = operatorProperty; + AlertSensitivity = alertSensitivity; + FailingPeriods = failingPeriods; + IgnoreDataBefore = ignoreDataBefore; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the operator used to compare the metric value against + /// the threshold. Possible values include: 'GreaterThan', 'LessThan', + /// 'GreaterOrLessThan' + /// + [JsonProperty(PropertyName = "operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets the extent of deviation required to trigger an alert. + /// This will affect how tight the threshold is to the metric series + /// pattern. Possible values include: 'Low', 'Medium', 'High' + /// + [JsonProperty(PropertyName = "alertSensitivity")] + public string AlertSensitivity { get; set; } + + /// + /// Gets or sets the minimum number of violations required within the + /// selected lookback time window required to raise an alert. + /// + [JsonProperty(PropertyName = "failingPeriods")] + public DynamicThresholdFailingPeriods FailingPeriods { get; set; } + + /// + /// Gets or sets use this option to set the date from which to start + /// learning the metric historical data and calculate the dynamic + /// thresholds (in ISO8601 format) + /// + [JsonProperty(PropertyName = "ignoreDataBefore")] + public System.DateTime? IgnoreDataBefore { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + if (AlertSensitivity == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AlertSensitivity"); + } + if (FailingPeriods == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "FailingPeriods"); + } + if (FailingPeriods != null) + { + FailingPeriods.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdFailingPeriods.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdFailingPeriods.cs new file mode 100644 index 000000000000..013569f048c5 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdFailingPeriods.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The minimum number of violations required within the selected lookback + /// time window required to raise an alert. + /// + public partial class DynamicThresholdFailingPeriods + { + /// + /// Initializes a new instance of the DynamicThresholdFailingPeriods + /// class. + /// + public DynamicThresholdFailingPeriods() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DynamicThresholdFailingPeriods + /// class. + /// + /// The number of aggregated + /// lookback points. The lookback time window is calculated based on + /// the aggregation granularity (windowSize) and the selected number of + /// aggregated points. + /// The number of violations to + /// trigger an alert. Should be smaller or equal to + /// numberOfEvaluationPeriods. + public DynamicThresholdFailingPeriods(double numberOfEvaluationPeriods, double minFailingPeriodsToAlert) + { + NumberOfEvaluationPeriods = numberOfEvaluationPeriods; + MinFailingPeriodsToAlert = minFailingPeriodsToAlert; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the number of aggregated lookback points. The lookback + /// time window is calculated based on the aggregation granularity + /// (windowSize) and the selected number of aggregated points. + /// + [JsonProperty(PropertyName = "numberOfEvaluationPeriods")] + public double NumberOfEvaluationPeriods { get; set; } + + /// + /// Gets or sets the number of violations to trigger an alert. Should + /// be smaller or equal to numberOfEvaluationPeriods. + /// + [JsonProperty(PropertyName = "minFailingPeriodsToAlert")] + public double MinFailingPeriodsToAlert { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdOperator.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdOperator.cs new file mode 100644 index 000000000000..a887196950ae --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdOperator.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for DynamicThresholdOperator. + /// + public static class DynamicThresholdOperator + { + public const string GreaterThan = "GreaterThan"; + public const string LessThan = "LessThan"; + public const string GreaterOrLessThan = "GreaterOrLessThan"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdSensitivity.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdSensitivity.cs new file mode 100644 index 000000000000..1b8751ab78b3 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/DynamicThresholdSensitivity.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for DynamicThresholdSensitivity. + /// + public static class DynamicThresholdSensitivity + { + public const string Low = "Low"; + public const string Medium = "Medium"; + public const string High = "High"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/EmailNotification.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/EmailNotification.cs new file mode 100644 index 000000000000..ba475ecb62f2 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/EmailNotification.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Email notification of an autoscale event. + /// + public partial class EmailNotification + { + /// + /// Initializes a new instance of the EmailNotification class. + /// + public EmailNotification() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EmailNotification class. + /// + /// a value indicating + /// whether to send email to subscription administrator. + /// a value indicating + /// whether to send email to subscription co-administrators. + /// the custom e-mails list. This value can + /// be null or empty, in which case this attribute will be + /// ignored. + public EmailNotification(bool? sendToSubscriptionAdministrator = default(bool?), bool? sendToSubscriptionCoAdministrators = default(bool?), IList customEmails = default(IList)) + { + SendToSubscriptionAdministrator = sendToSubscriptionAdministrator; + SendToSubscriptionCoAdministrators = sendToSubscriptionCoAdministrators; + CustomEmails = customEmails; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a value indicating whether to send email to + /// subscription administrator. + /// + [JsonProperty(PropertyName = "sendToSubscriptionAdministrator")] + public bool? SendToSubscriptionAdministrator { get; set; } + + /// + /// Gets or sets a value indicating whether to send email to + /// subscription co-administrators. + /// + [JsonProperty(PropertyName = "sendToSubscriptionCoAdministrators")] + public bool? SendToSubscriptionCoAdministrators { get; set; } + + /// + /// Gets or sets the custom e-mails list. This value can be null or + /// empty, in which case this attribute will be ignored. + /// + [JsonProperty(PropertyName = "customEmails")] + public IList CustomEmails { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorAdditionalInfo.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorAdditionalInfo.cs new file mode 100644 index 000000000000..05bf1fbd6ec3 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorAdditionalInfo.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource management error additional info. + /// + public partial class ErrorAdditionalInfo + { + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + public ErrorAdditionalInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + /// The additional info type. + /// The additional info. + public ErrorAdditionalInfo(string type = default(string), object info = default(object)) + { + Type = type; + Info = info; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the additional info type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the additional info. + /// + [JsonProperty(PropertyName = "info")] + public object Info { get; private set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponse.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..2f93fbb9e247 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponse.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes the format of Error response. + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// Error code + /// Error message indicating why the operation + /// failed. + public ErrorResponse(string code = default(string), string message = default(string)) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error code + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets error message indicating why the operation failed. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseCommon.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseCommon.cs new file mode 100644 index 000000000000..03e89dfa4cbc --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseCommon.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The resource management error response. + /// + public partial class ErrorResponseCommon : ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponseCommon class. + /// + public ErrorResponseCommon() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponseCommon class. + /// + /// Error code + /// Error message indicating why the operation + /// failed. + /// The error details. + /// The error additional info. + public ErrorResponseCommon(string code = default(string), string message = default(string), IList details = default(IList), IList additionalInfo = default(IList)) + : base(code, message) + { + Details = details; + AdditionalInfo = additionalInfo; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the error details. + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; private set; } + + /// + /// Gets the error additional info. + /// + [JsonProperty(PropertyName = "additionalInfo")] + public IList AdditionalInfo { get; private set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseCommonException.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseCommonException.cs new file mode 100644 index 000000000000..f68f9794927a --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseCommonException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponseCommon + /// information. + /// + public partial class ErrorResponseCommonException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorResponseCommon Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseCommonException class. + /// + public ErrorResponseCommonException() + { + } + + /// + /// Initializes a new instance of the ErrorResponseCommonException class. + /// + /// The exception message. + public ErrorResponseCommonException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponseCommonException class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseCommonException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseException.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..ad8fecdf5136 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponse + /// information. + /// + public partial class ErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + public ErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/EventData.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/EventData.cs new file mode 100644 index 000000000000..91dc9e9d304d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/EventData.cs @@ -0,0 +1,339 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The Azure event log entries are of type EventData + /// + public partial class EventData + { + /// + /// Initializes a new instance of the EventData class. + /// + public EventData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EventData class. + /// + /// The sender authorization + /// information. + /// key value pairs to identify ARM + /// permissions. + /// the email address of the user who has + /// performed the operation, the UPN claim or SPN claim based on + /// availability. + /// the description of the event. + /// the Id of this event as required by ARM for RBAC. + /// It contains the EventDataID and a timestamp information. + /// the event data Id. This is a unique + /// identifier for an event. + /// the correlation Id, usually a GUID in + /// the string format. The correlation Id is shared among the events + /// that belong to the same uber operation. + /// the event name. This value should not be + /// confused with OperationName. For practical purposes, OperationName + /// might be more appealing to end users. + /// the event category. + /// the HTTP request info. Usually includes + /// the 'clientRequestId', 'clientIpAddress' (IP address of the user + /// who initiated the event) and 'method' (HTTP method e.g. + /// PUT). + /// the event level. Possible values include: + /// 'Critical', 'Error', 'Warning', 'Informational', 'Verbose' + /// the resource group name of the + /// impacted resource. + /// the resource provider name of + /// the impacted resource. + /// the resource uri that uniquely identifies + /// the resource that caused this event. + /// the resource type + /// It is usually a GUID shared among the + /// events corresponding to single operation. This value should not be + /// confused with EventName. + /// the operation name. + /// the set of <Key, Value> pairs + /// (usually a Dictionary<String, String>) that includes details + /// about the event. + /// a string describing the status of the + /// operation. Some typical values are: Started, In progress, + /// Succeeded, Failed, Resolved. + /// the event sub status. Most of the time, + /// when included, this captures the HTTP status code of the REST call. + /// Common values are: OK (HTTP Status Code: 200), Created (HTTP Status + /// Code: 201), Accepted (HTTP Status Code: 202), No Content (HTTP + /// Status Code: 204), Bad Request(HTTP Status Code: 400), Not Found + /// (HTTP Status Code: 404), Conflict (HTTP Status Code: 409), Internal + /// Server Error (HTTP Status Code: 500), Service Unavailable (HTTP + /// Status Code:503), Gateway Timeout (HTTP Status Code: 504) + /// the timestamp of when the event was + /// generated by the Azure service processing the request corresponding + /// the event. It in ISO 8601 format. + /// the timestamp of when the event + /// became available for querying via this API. It is in ISO 8601 + /// format. This value should not be confused eventTimestamp. As there + /// might be a delay between the occurrence time of the event, and the + /// time that the event is submitted to the Azure logging + /// infrastructure. + /// the Azure subscription Id usually a + /// GUID. + /// the Azure tenant Id + public EventData(SenderAuthorization authorization = default(SenderAuthorization), IDictionary claims = default(IDictionary), string caller = default(string), string description = default(string), string id = default(string), string eventDataId = default(string), string correlationId = default(string), LocalizableString eventName = default(LocalizableString), LocalizableString category = default(LocalizableString), HttpRequestInfo httpRequest = default(HttpRequestInfo), EventLevel? level = default(EventLevel?), string resourceGroupName = default(string), LocalizableString resourceProviderName = default(LocalizableString), string resourceId = default(string), LocalizableString resourceType = default(LocalizableString), string operationId = default(string), LocalizableString operationName = default(LocalizableString), IDictionary properties = default(IDictionary), LocalizableString status = default(LocalizableString), LocalizableString subStatus = default(LocalizableString), System.DateTime? eventTimestamp = default(System.DateTime?), System.DateTime? submissionTimestamp = default(System.DateTime?), string subscriptionId = default(string), string tenantId = default(string)) + { + Authorization = authorization; + Claims = claims; + Caller = caller; + Description = description; + Id = id; + EventDataId = eventDataId; + CorrelationId = correlationId; + EventName = eventName; + Category = category; + HttpRequest = httpRequest; + Level = level; + ResourceGroupName = resourceGroupName; + ResourceProviderName = resourceProviderName; + ResourceId = resourceId; + ResourceType = resourceType; + OperationId = operationId; + OperationName = operationName; + Properties = properties; + Status = status; + SubStatus = subStatus; + EventTimestamp = eventTimestamp; + SubmissionTimestamp = submissionTimestamp; + SubscriptionId = subscriptionId; + TenantId = tenantId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the sender authorization information. + /// + [JsonProperty(PropertyName = "authorization")] + public SenderAuthorization Authorization { get; private set; } + + /// + /// Gets key value pairs to identify ARM permissions. + /// + [JsonProperty(PropertyName = "claims")] + public IDictionary Claims { get; private set; } + + /// + /// Gets the email address of the user who has performed the operation, + /// the UPN claim or SPN claim based on availability. + /// + [JsonProperty(PropertyName = "caller")] + public string Caller { get; private set; } + + /// + /// Gets the description of the event. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + /// + /// Gets the Id of this event as required by ARM for RBAC. It contains + /// the EventDataID and a timestamp information. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the event data Id. This is a unique identifier for an event. + /// + [JsonProperty(PropertyName = "eventDataId")] + public string EventDataId { get; private set; } + + /// + /// Gets the correlation Id, usually a GUID in the string format. The + /// correlation Id is shared among the events that belong to the same + /// uber operation. + /// + [JsonProperty(PropertyName = "correlationId")] + public string CorrelationId { get; private set; } + + /// + /// Gets the event name. This value should not be confused with + /// OperationName. For practical purposes, OperationName might be more + /// appealing to end users. + /// + [JsonProperty(PropertyName = "eventName")] + public LocalizableString EventName { get; private set; } + + /// + /// Gets the event category. + /// + [JsonProperty(PropertyName = "category")] + public LocalizableString Category { get; private set; } + + /// + /// Gets the HTTP request info. Usually includes the 'clientRequestId', + /// 'clientIpAddress' (IP address of the user who initiated the event) + /// and 'method' (HTTP method e.g. PUT). + /// + [JsonProperty(PropertyName = "httpRequest")] + public HttpRequestInfo HttpRequest { get; private set; } + + /// + /// Gets the event level. Possible values include: 'Critical', 'Error', + /// 'Warning', 'Informational', 'Verbose' + /// + [JsonProperty(PropertyName = "level")] + public EventLevel? Level { get; private set; } + + /// + /// Gets the resource group name of the impacted resource. + /// + [JsonProperty(PropertyName = "resourceGroupName")] + public string ResourceGroupName { get; private set; } + + /// + /// Gets the resource provider name of the impacted resource. + /// + [JsonProperty(PropertyName = "resourceProviderName")] + public LocalizableString ResourceProviderName { get; private set; } + + /// + /// Gets the resource uri that uniquely identifies the resource that + /// caused this event. + /// + [JsonProperty(PropertyName = "resourceId")] + public string ResourceId { get; private set; } + + /// + /// Gets the resource type + /// + [JsonProperty(PropertyName = "resourceType")] + public LocalizableString ResourceType { get; private set; } + + /// + /// Gets it is usually a GUID shared among the events corresponding to + /// single operation. This value should not be confused with EventName. + /// + [JsonProperty(PropertyName = "operationId")] + public string OperationId { get; private set; } + + /// + /// Gets the operation name. + /// + [JsonProperty(PropertyName = "operationName")] + public LocalizableString OperationName { get; private set; } + + /// + /// Gets the set of &lt;Key, Value&gt; pairs (usually a + /// Dictionary&lt;String, String&gt;) that includes details + /// about the event. + /// + [JsonProperty(PropertyName = "properties")] + public IDictionary Properties { get; private set; } + + /// + /// Gets a string describing the status of the operation. Some typical + /// values are: Started, In progress, Succeeded, Failed, Resolved. + /// + [JsonProperty(PropertyName = "status")] + public LocalizableString Status { get; private set; } + + /// + /// Gets the event sub status. Most of the time, when included, this + /// captures the HTTP status code of the REST call. Common values are: + /// OK (HTTP Status Code: 200), Created (HTTP Status Code: 201), + /// Accepted (HTTP Status Code: 202), No Content (HTTP Status Code: + /// 204), Bad Request(HTTP Status Code: 400), Not Found (HTTP Status + /// Code: 404), Conflict (HTTP Status Code: 409), Internal Server Error + /// (HTTP Status Code: 500), Service Unavailable (HTTP Status + /// Code:503), Gateway Timeout (HTTP Status Code: 504) + /// + [JsonProperty(PropertyName = "subStatus")] + public LocalizableString SubStatus { get; private set; } + + /// + /// Gets the timestamp of when the event was generated by the Azure + /// service processing the request corresponding the event. It in ISO + /// 8601 format. + /// + [JsonProperty(PropertyName = "eventTimestamp")] + public System.DateTime? EventTimestamp { get; private set; } + + /// + /// Gets the timestamp of when the event became available for querying + /// via this API. It is in ISO 8601 format. This value should not be + /// confused eventTimestamp. As there might be a delay between the + /// occurrence time of the event, and the time that the event is + /// submitted to the Azure logging infrastructure. + /// + [JsonProperty(PropertyName = "submissionTimestamp")] + public System.DateTime? SubmissionTimestamp { get; private set; } + + /// + /// Gets the Azure subscription Id usually a GUID. + /// + [JsonProperty(PropertyName = "subscriptionId")] + public string SubscriptionId { get; private set; } + + /// + /// Gets the Azure tenant Id + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (EventName != null) + { + EventName.Validate(); + } + if (Category != null) + { + Category.Validate(); + } + if (ResourceProviderName != null) + { + ResourceProviderName.Validate(); + } + if (ResourceType != null) + { + ResourceType.Validate(); + } + if (OperationName != null) + { + OperationName.Validate(); + } + if (Status != null) + { + Status.Validate(); + } + if (SubStatus != null) + { + SubStatus.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/EventLevel.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/EventLevel.cs new file mode 100644 index 000000000000..ac449a2bab87 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/EventLevel.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for EventLevel. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum EventLevel + { + [EnumMember(Value = "Critical")] + Critical, + [EnumMember(Value = "Error")] + Error, + [EnumMember(Value = "Warning")] + Warning, + [EnumMember(Value = "Informational")] + Informational, + [EnumMember(Value = "Verbose")] + Verbose + } + internal static class EventLevelEnumExtension + { + internal static string ToSerializedValue(this EventLevel? value) + { + return value == null ? null : ((EventLevel)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this EventLevel value) + { + switch( value ) + { + case EventLevel.Critical: + return "Critical"; + case EventLevel.Error: + return "Error"; + case EventLevel.Warning: + return "Warning"; + case EventLevel.Informational: + return "Informational"; + case EventLevel.Verbose: + return "Verbose"; + } + return null; + } + + internal static EventLevel? ParseEventLevel(this string value) + { + switch( value ) + { + case "Critical": + return EventLevel.Critical; + case "Error": + return EventLevel.Error; + case "Warning": + return EventLevel.Warning; + case "Informational": + return EventLevel.Informational; + case "Verbose": + return EventLevel.Verbose; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/HttpRequestInfo.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/HttpRequestInfo.cs new file mode 100644 index 000000000000..142ff887d3f5 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/HttpRequestInfo.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The Http request info. + /// + public partial class HttpRequestInfo + { + /// + /// Initializes a new instance of the HttpRequestInfo class. + /// + public HttpRequestInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HttpRequestInfo class. + /// + /// the client request id. + /// the client Ip Address + /// the Http request method. + /// the Uri. + public HttpRequestInfo(string clientRequestId = default(string), string clientIpAddress = default(string), string method = default(string), string uri = default(string)) + { + ClientRequestId = clientRequestId; + ClientIpAddress = clientIpAddress; + Method = method; + Uri = uri; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the client request id. + /// + [JsonProperty(PropertyName = "clientRequestId")] + public string ClientRequestId { get; set; } + + /// + /// Gets or sets the client Ip Address + /// + [JsonProperty(PropertyName = "clientIpAddress")] + public string ClientIpAddress { get; set; } + + /// + /// Gets or sets the Http request method. + /// + [JsonProperty(PropertyName = "method")] + public string Method { get; set; } + + /// + /// Gets or sets the Uri. + /// + [JsonProperty(PropertyName = "uri")] + public string Uri { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/LocalizableString.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LocalizableString.cs new file mode 100644 index 000000000000..6db03f4d1e61 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LocalizableString.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The localizable string class. + /// + public partial class LocalizableString + { + /// + /// Initializes a new instance of the LocalizableString class. + /// + public LocalizableString() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LocalizableString class. + /// + /// the invariant value. + /// the locale specific value. + public LocalizableString(string value, string localizedValue = default(string)) + { + Value = value; + LocalizedValue = localizedValue; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the invariant value. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Gets or sets the locale specific value. + /// + [JsonProperty(PropertyName = "localizedValue")] + public string LocalizedValue { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/LocationThresholdRuleCondition.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LocationThresholdRuleCondition.cs new file mode 100644 index 000000000000..d8cfb0db1d24 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LocationThresholdRuleCondition.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A rule condition based on a certain number of locations failing. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition")] + public partial class LocationThresholdRuleCondition : RuleCondition + { + /// + /// Initializes a new instance of the LocationThresholdRuleCondition + /// class. + /// + public LocationThresholdRuleCondition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LocationThresholdRuleCondition + /// class. + /// + /// the number of locations that must + /// fail to activate the alert. + /// the resource from which the rule collects + /// its data. For this type dataSource will always be of type + /// RuleMetricDataSource. + /// the period of time (in ISO 8601 duration + /// format) that is used to monitor alert activity based on the + /// threshold. If specified then it must be between 5 minutes and 1 + /// day. + public LocationThresholdRuleCondition(int failedLocationCount, RuleDataSource dataSource = default(RuleDataSource), System.TimeSpan? windowSize = default(System.TimeSpan?)) + : base(dataSource) + { + WindowSize = windowSize; + FailedLocationCount = failedLocationCount; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the period of time (in ISO 8601 duration format) that + /// is used to monitor alert activity based on the threshold. If + /// specified then it must be between 5 minutes and 1 day. + /// + [JsonProperty(PropertyName = "windowSize")] + public System.TimeSpan? WindowSize { get; set; } + + /// + /// Gets or sets the number of locations that must fail to activate the + /// alert. + /// + [JsonProperty(PropertyName = "failedLocationCount")] + public int FailedLocationCount { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (FailedLocationCount < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "FailedLocationCount", 0); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogProfileResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogProfileResource.cs new file mode 100644 index 000000000000..a709d9399b93 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogProfileResource.cs @@ -0,0 +1,138 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The log profile resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class LogProfileResource : Resource + { + /// + /// Initializes a new instance of the LogProfileResource class. + /// + public LogProfileResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogProfileResource class. + /// + /// Resource location + /// List of regions for which Activity Log + /// events should be stored or streamed. It is a comma separated list + /// of valid ARM locations including the 'global' location. + /// the categories of the logs. These + /// categories are created as is convenient to the user. Some values + /// are: 'Write', 'Delete', and/or 'Action.' + /// the retention policy for the events + /// in the log. + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// the resource id of the storage + /// account to which you would like to send the Activity Log. + /// The service bus rule ID of the + /// service bus namespace in which you would like to have Event Hubs + /// created for streaming the Activity Log. The rule ID is of the + /// format: '{service bus resource ID}/authorizationrules/{key + /// name}'. + public LogProfileResource(string location, IList locations, IList categories, RetentionPolicy retentionPolicy, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string storageAccountId = default(string), string serviceBusRuleId = default(string)) + : base(location, id, name, type, tags) + { + StorageAccountId = storageAccountId; + ServiceBusRuleId = serviceBusRuleId; + Locations = locations; + Categories = categories; + RetentionPolicy = retentionPolicy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource id of the storage account to which you + /// would like to send the Activity Log. + /// + [JsonProperty(PropertyName = "properties.storageAccountId")] + public string StorageAccountId { get; set; } + + /// + /// Gets or sets the service bus rule ID of the service bus namespace + /// in which you would like to have Event Hubs created for streaming + /// the Activity Log. The rule ID is of the format: '{service bus + /// resource ID}/authorizationrules/{key name}'. + /// + [JsonProperty(PropertyName = "properties.serviceBusRuleId")] + public string ServiceBusRuleId { get; set; } + + /// + /// Gets or sets list of regions for which Activity Log events should + /// be stored or streamed. It is a comma separated list of valid ARM + /// locations including the 'global' location. + /// + [JsonProperty(PropertyName = "properties.locations")] + public IList Locations { get; set; } + + /// + /// Gets or sets the categories of the logs. These categories are + /// created as is convenient to the user. Some values are: 'Write', + /// 'Delete', and/or 'Action.' + /// + [JsonProperty(PropertyName = "properties.categories")] + public IList Categories { get; set; } + + /// + /// Gets or sets the retention policy for the events in the log. + /// + [JsonProperty(PropertyName = "properties.retentionPolicy")] + public RetentionPolicy RetentionPolicy { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Locations == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Locations"); + } + if (Categories == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Categories"); + } + if (RetentionPolicy == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RetentionPolicy"); + } + if (RetentionPolicy != null) + { + RetentionPolicy.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogProfileResourcePatch.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogProfileResourcePatch.cs new file mode 100644 index 000000000000..a3622df0b0ea --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogProfileResourcePatch.cs @@ -0,0 +1,139 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The log profile resource for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class LogProfileResourcePatch + { + /// + /// Initializes a new instance of the LogProfileResourcePatch class. + /// + public LogProfileResourcePatch() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogProfileResourcePatch class. + /// + /// List of regions for which Activity Log + /// events should be stored or streamed. It is a comma separated list + /// of valid ARM locations including the 'global' location. + /// the categories of the logs. These + /// categories are created as is convenient to the user. Some values + /// are: 'Write', 'Delete', and/or 'Action.' + /// the retention policy for the events + /// in the log. + /// Resource tags + /// the resource id of the storage + /// account to which you would like to send the Activity Log. + /// The service bus rule ID of the + /// service bus namespace in which you would like to have Event Hubs + /// created for streaming the Activity Log. The rule ID is of the + /// format: '{service bus resource ID}/authorizationrules/{key + /// name}'. + public LogProfileResourcePatch(IList locations, IList categories, RetentionPolicy retentionPolicy, IDictionary tags = default(IDictionary), string storageAccountId = default(string), string serviceBusRuleId = default(string)) + { + Tags = tags; + StorageAccountId = storageAccountId; + ServiceBusRuleId = serviceBusRuleId; + Locations = locations; + Categories = categories; + RetentionPolicy = retentionPolicy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the resource id of the storage account to which you + /// would like to send the Activity Log. + /// + [JsonProperty(PropertyName = "properties.storageAccountId")] + public string StorageAccountId { get; set; } + + /// + /// Gets or sets the service bus rule ID of the service bus namespace + /// in which you would like to have Event Hubs created for streaming + /// the Activity Log. The rule ID is of the format: '{service bus + /// resource ID}/authorizationrules/{key name}'. + /// + [JsonProperty(PropertyName = "properties.serviceBusRuleId")] + public string ServiceBusRuleId { get; set; } + + /// + /// Gets or sets list of regions for which Activity Log events should + /// be stored or streamed. It is a comma separated list of valid ARM + /// locations including the 'global' location. + /// + [JsonProperty(PropertyName = "properties.locations")] + public IList Locations { get; set; } + + /// + /// Gets or sets the categories of the logs. These categories are + /// created as is convenient to the user. Some values are: 'Write', + /// 'Delete', and/or 'Action.' + /// + [JsonProperty(PropertyName = "properties.categories")] + public IList Categories { get; set; } + + /// + /// Gets or sets the retention policy for the events in the log. + /// + [JsonProperty(PropertyName = "properties.retentionPolicy")] + public RetentionPolicy RetentionPolicy { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Locations == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Locations"); + } + if (Categories == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Categories"); + } + if (RetentionPolicy == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "RetentionPolicy"); + } + if (RetentionPolicy != null) + { + RetentionPolicy.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogSettings.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogSettings.cs new file mode 100644 index 000000000000..fed0ef407cda --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/LogSettings.cs @@ -0,0 +1,89 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Part of MultiTenantDiagnosticSettings. Specifies the settings for a + /// particular log. + /// + public partial class LogSettings + { + /// + /// Initializes a new instance of the LogSettings class. + /// + public LogSettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LogSettings class. + /// + /// a value indicating whether this log is + /// enabled. + /// Name of a Diagnostic Log category for a + /// resource type this setting is applied to. To obtain the list of + /// Diagnostic Log categories for a resource, first perform a GET + /// diagnostic settings operation. + /// the retention policy for this + /// log. + public LogSettings(bool enabled, string category = default(string), RetentionPolicy retentionPolicy = default(RetentionPolicy)) + { + Category = category; + Enabled = enabled; + RetentionPolicy = retentionPolicy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of a Diagnostic Log category for a resource type + /// this setting is applied to. To obtain the list of Diagnostic Log + /// categories for a resource, first perform a GET diagnostic settings + /// operation. + /// + [JsonProperty(PropertyName = "category")] + public string Category { get; set; } + + /// + /// Gets or sets a value indicating whether this log is enabled. + /// + [JsonProperty(PropertyName = "enabled")] + public bool Enabled { get; set; } + + /// + /// Gets or sets the retention policy for this log. + /// + [JsonProperty(PropertyName = "retentionPolicy")] + public RetentionPolicy RetentionPolicy { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RetentionPolicy != null) + { + RetentionPolicy.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ManagementEventAggregationCondition.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ManagementEventAggregationCondition.cs new file mode 100644 index 000000000000..0e2b2b3efa68 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ManagementEventAggregationCondition.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// How the data that is collected should be combined over time. + /// + public partial class ManagementEventAggregationCondition + { + /// + /// Initializes a new instance of the + /// ManagementEventAggregationCondition class. + /// + public ManagementEventAggregationCondition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ManagementEventAggregationCondition class. + /// + /// the condition operator. Possible + /// values include: 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + /// 'LessThanOrEqual' + /// The threshold value that activates the + /// alert. + /// the period of time (in ISO 8601 duration + /// format) that is used to monitor alert activity based on the + /// threshold. If specified then it must be between 5 minutes and 1 + /// day. + public ManagementEventAggregationCondition(ConditionOperator? operatorProperty = default(ConditionOperator?), double? threshold = default(double?), System.TimeSpan? windowSize = default(System.TimeSpan?)) + { + OperatorProperty = operatorProperty; + Threshold = threshold; + WindowSize = windowSize; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the condition operator. Possible values include: + /// 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + /// + [JsonProperty(PropertyName = "operator")] + public ConditionOperator? OperatorProperty { get; set; } + + /// + /// Gets or sets the threshold value that activates the alert. + /// + [JsonProperty(PropertyName = "threshold")] + public double? Threshold { get; set; } + + /// + /// Gets or sets the period of time (in ISO 8601 duration format) that + /// is used to monitor alert activity based on the threshold. If + /// specified then it must be between 5 minutes and 1 day. + /// + [JsonProperty(PropertyName = "windowSize")] + public System.TimeSpan? WindowSize { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ManagementEventRuleCondition.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ManagementEventRuleCondition.cs new file mode 100644 index 000000000000..4ede5a411148 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ManagementEventRuleCondition.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A management event rule condition. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition")] + public partial class ManagementEventRuleCondition : RuleCondition + { + /// + /// Initializes a new instance of the ManagementEventRuleCondition + /// class. + /// + public ManagementEventRuleCondition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementEventRuleCondition + /// class. + /// + /// the resource from which the rule collects + /// its data. For this type dataSource will always be of type + /// RuleMetricDataSource. + /// How the data that is collected should be + /// combined over time and when the alert is activated. Note that for + /// management event alerts aggregation is optional – if it is not + /// provided then any event will cause the alert to activate. + public ManagementEventRuleCondition(RuleDataSource dataSource = default(RuleDataSource), ManagementEventAggregationCondition aggregation = default(ManagementEventAggregationCondition)) + : base(dataSource) + { + Aggregation = aggregation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets how the data that is collected should be combined over + /// time and when the alert is activated. Note that for management + /// event alerts aggregation is optional – if it is not provided then + /// any event will cause the alert to activate. + /// + [JsonProperty(PropertyName = "aggregation")] + public ManagementEventAggregationCondition Aggregation { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetadataValue.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetadataValue.cs new file mode 100644 index 000000000000..84b70cfdc04d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetadataValue.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a metric metadata value. + /// + public partial class MetadataValue + { + /// + /// Initializes a new instance of the MetadataValue class. + /// + public MetadataValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetadataValue class. + /// + /// the name of the metadata. + /// the value of the metadata. + public MetadataValue(LocalizableString name = default(LocalizableString), string value = default(string)) + { + Name = name; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the metadata. + /// + [JsonProperty(PropertyName = "name")] + public LocalizableString Name { get; set; } + + /// + /// Gets or sets the value of the metadata. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name != null) + { + Name.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/Metric.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Metric.cs new file mode 100644 index 000000000000..003ddb21c4c0 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Metric.cs @@ -0,0 +1,159 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The result data of a query. + /// + public partial class Metric + { + /// + /// Initializes a new instance of the Metric class. + /// + public Metric() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Metric class. + /// + /// the metric Id. + /// the resource type of the metric + /// resource. + /// the name and the display name of the metric, + /// i.e. it is localizable string. + /// The unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'CountPerSecond', 'BytesPerSecond', + /// 'Percent', 'MilliSeconds', 'ByteSeconds', 'Unspecified', 'Cores', + /// 'MilliCores', 'NanoCores', 'BitsPerSecond' + /// the time series returned when a data query + /// is performed. + /// Detailed description of this + /// metric. + /// 'Success' or the error details on query + /// failures for this metric. + /// Error message encountered querying this + /// specific metric. + public Metric(string id, string type, LocalizableString name, string unit, IList timeseries, string displayDescription = default(string), string errorCode = default(string), string errorMessage = default(string)) + { + Id = id; + Type = type; + Name = name; + DisplayDescription = displayDescription; + ErrorCode = errorCode; + ErrorMessage = errorMessage; + Unit = unit; + Timeseries = timeseries; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the metric Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the resource type of the metric resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the name and the display name of the metric, i.e. it + /// is localizable string. + /// + [JsonProperty(PropertyName = "name")] + public LocalizableString Name { get; set; } + + /// + /// Gets or sets detailed description of this metric. + /// + [JsonProperty(PropertyName = "displayDescription")] + public string DisplayDescription { get; set; } + + /// + /// Gets or sets 'Success' or the error details on query failures for + /// this metric. + /// + [JsonProperty(PropertyName = "errorCode")] + public string ErrorCode { get; set; } + + /// + /// Gets or sets error message encountered querying this specific + /// metric. + /// + [JsonProperty(PropertyName = "errorMessage")] + public string ErrorMessage { get; set; } + + /// + /// Gets or sets the unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'CountPerSecond', 'BytesPerSecond', + /// 'Percent', 'MilliSeconds', 'ByteSeconds', 'Unspecified', 'Cores', + /// 'MilliCores', 'NanoCores', 'BitsPerSecond' + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// Gets or sets the time series returned when a data query is + /// performed. + /// + [JsonProperty(PropertyName = "timeseries")] + public IList Timeseries { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Unit == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Unit"); + } + if (Timeseries == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Timeseries"); + } + if (Name != null) + { + Name.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertAction.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertAction.cs new file mode 100644 index 000000000000..34d8307f5947 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertAction.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An alert action. + /// + public partial class MetricAlertAction + { + /// + /// Initializes a new instance of the MetricAlertAction class. + /// + public MetricAlertAction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertAction class. + /// + /// the id of the action group to + /// use. + /// This field allows specifying custom + /// properties, which would be appended to the alert payload sent as + /// input to the webhook. + public MetricAlertAction(string actionGroupId = default(string), IDictionary webHookProperties = default(IDictionary)) + { + ActionGroupId = actionGroupId; + WebHookProperties = webHookProperties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the id of the action group to use. + /// + [JsonProperty(PropertyName = "actionGroupId")] + public string ActionGroupId { get; set; } + + /// + /// Gets or sets this field allows specifying custom properties, which + /// would be appended to the alert payload sent as input to the + /// webhook. + /// + [JsonProperty(PropertyName = "webHookProperties")] + public IDictionary WebHookProperties { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertCriteria.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertCriteria.cs new file mode 100644 index 000000000000..e5d00fa0cdee --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertCriteria.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The rule criteria that defines the conditions of the alert rule. + /// + [Newtonsoft.Json.JsonObject("MetricAlertCriteria")] + public partial class MetricAlertCriteria + { + /// + /// Initializes a new instance of the MetricAlertCriteria class. + /// + public MetricAlertCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertCriteria class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + public MetricAlertCriteria(IDictionary additionalProperties = default(IDictionary)) + { + AdditionalProperties = additionalProperties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets unmatched properties from the message are deserialized + /// this collection + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.cs new file mode 100644 index 000000000000..105d3f132ee8 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertMultipleResourceMultipleMetricCriteria.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies the metric alert criteria for multiple resource that has + /// multiple metric criteria. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria")] + public partial class MetricAlertMultipleResourceMultipleMetricCriteria : MetricAlertCriteria + { + /// + /// Initializes a new instance of the + /// MetricAlertMultipleResourceMultipleMetricCriteria class. + /// + public MetricAlertMultipleResourceMultipleMetricCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MetricAlertMultipleResourceMultipleMetricCriteria class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + /// the list of multiple metric criteria for this + /// 'all of' operation. + public MetricAlertMultipleResourceMultipleMetricCriteria(IDictionary additionalProperties = default(IDictionary), IList allOf = default(IList)) + : base(additionalProperties) + { + AllOf = allOf; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of multiple metric criteria for this 'all of' + /// operation. + /// + [JsonProperty(PropertyName = "allOf")] + public IList AllOf { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertResource.cs new file mode 100644 index 000000000000..f61516f319a7 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertResource.cs @@ -0,0 +1,205 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The metric alert resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class MetricAlertResource : Resource + { + /// + /// Initializes a new instance of the MetricAlertResource class. + /// + public MetricAlertResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertResource class. + /// + /// Resource location + /// Alert severity {0, 1, 2, 3, 4} + /// the flag that indicates whether the metric + /// alert is enabled. + /// the list of resource id's that this metric + /// alert is scoped to. + /// how often the metric alert is + /// evaluated represented in ISO 8601 duration format. + /// the period of time (in ISO 8601 duration + /// format) that is used to monitor alert activity based on the + /// threshold. + /// defines the specific alert criteria + /// information. + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + /// the description of the metric alert that + /// will be included in the alert email. + /// the resource type of the target + /// resource(s) on which the alert is created/updated. Mandatory if the + /// scope contains a subscription, resource group, or more than one + /// resource. + /// the region of the target + /// resource(s) on which the alert is created/updated. Mandatory if the + /// scope contains a subscription, resource group, or more than one + /// resource. + /// the flag that indicates whether the + /// alert should be auto resolved or not. The default is true. + /// the array of actions that are performed when + /// the alert rule becomes active, and when an alert condition is + /// resolved. + /// Last time the rule was updated in + /// ISO8601 format. + /// the value indicating whether this alert + /// rule is migrated. + public MetricAlertResource(string location, int severity, bool enabled, IList scopes, System.TimeSpan evaluationFrequency, System.TimeSpan windowSize, MetricAlertCriteria criteria, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string description = default(string), string targetResourceType = default(string), string targetResourceRegion = default(string), bool? autoMitigate = default(bool?), IList actions = default(IList), System.DateTime? lastUpdatedTime = default(System.DateTime?), bool? isMigrated = default(bool?)) + : base(location, id, name, type, tags) + { + Description = description; + Severity = severity; + Enabled = enabled; + Scopes = scopes; + EvaluationFrequency = evaluationFrequency; + WindowSize = windowSize; + TargetResourceType = targetResourceType; + TargetResourceRegion = targetResourceRegion; + Criteria = criteria; + AutoMitigate = autoMitigate; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + IsMigrated = isMigrated; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the description of the metric alert that will be + /// included in the alert email. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets alert severity {0, 1, 2, 3, 4} + /// + [JsonProperty(PropertyName = "properties.severity")] + public int Severity { get; set; } + + /// + /// Gets or sets the flag that indicates whether the metric alert is + /// enabled. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool Enabled { get; set; } + + /// + /// Gets or sets the list of resource id's that this metric alert is + /// scoped to. + /// + [JsonProperty(PropertyName = "properties.scopes")] + public IList Scopes { get; set; } + + /// + /// Gets or sets how often the metric alert is evaluated represented in + /// ISO 8601 duration format. + /// + [JsonProperty(PropertyName = "properties.evaluationFrequency")] + public System.TimeSpan EvaluationFrequency { get; set; } + + /// + /// Gets or sets the period of time (in ISO 8601 duration format) that + /// is used to monitor alert activity based on the threshold. + /// + [JsonProperty(PropertyName = "properties.windowSize")] + public System.TimeSpan WindowSize { get; set; } + + /// + /// Gets or sets the resource type of the target resource(s) on which + /// the alert is created/updated. Mandatory if the scope contains a + /// subscription, resource group, or more than one resource. + /// + [JsonProperty(PropertyName = "properties.targetResourceType")] + public string TargetResourceType { get; set; } + + /// + /// Gets or sets the region of the target resource(s) on which the + /// alert is created/updated. Mandatory if the scope contains a + /// subscription, resource group, or more than one resource. + /// + [JsonProperty(PropertyName = "properties.targetResourceRegion")] + public string TargetResourceRegion { get; set; } + + /// + /// Gets or sets defines the specific alert criteria information. + /// + [JsonProperty(PropertyName = "properties.criteria")] + public MetricAlertCriteria Criteria { get; set; } + + /// + /// Gets or sets the flag that indicates whether the alert should be + /// auto resolved or not. The default is true. + /// + [JsonProperty(PropertyName = "properties.autoMitigate")] + public bool? AutoMitigate { get; set; } + + /// + /// Gets or sets the array of actions that are performed when the alert + /// rule becomes active, and when an alert condition is resolved. + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + /// + /// Gets last time the rule was updated in ISO8601 format. + /// + [JsonProperty(PropertyName = "properties.lastUpdatedTime")] + public System.DateTime? LastUpdatedTime { get; private set; } + + /// + /// Gets the value indicating whether this alert rule is migrated. + /// + [JsonProperty(PropertyName = "properties.isMigrated")] + public bool? IsMigrated { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Scopes == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Scopes"); + } + if (Criteria == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Criteria"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertResourcePatch.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertResourcePatch.cs new file mode 100644 index 000000000000..79942cfb0c2b --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertResourcePatch.cs @@ -0,0 +1,187 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The metric alert resource for patch operations. + /// + [Rest.Serialization.JsonTransformation] + public partial class MetricAlertResourcePatch + { + /// + /// Initializes a new instance of the MetricAlertResourcePatch class. + /// + public MetricAlertResourcePatch() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertResourcePatch class. + /// + /// Resource tags + /// the description of the metric alert that + /// will be included in the alert email. + /// Alert severity {0, 1, 2, 3, 4} + /// the flag that indicates whether the metric + /// alert is enabled. + /// the list of resource id's that this metric + /// alert is scoped to. + /// how often the metric alert is + /// evaluated represented in ISO 8601 duration format. + /// the period of time (in ISO 8601 duration + /// format) that is used to monitor alert activity based on the + /// threshold. + /// the resource type of the target + /// resource(s) on which the alert is created/updated. Mandatory for + /// MultipleResourceMultipleMetricCriteria. + /// the region of the target + /// resource(s) on which the alert is created/updated. Mandatory for + /// MultipleResourceMultipleMetricCriteria. + /// defines the specific alert criteria + /// information. + /// the flag that indicates whether the + /// alert should be auto resolved or not. The default is true. + /// the array of actions that are performed when + /// the alert rule becomes active, and when an alert condition is + /// resolved. + /// Last time the rule was updated in + /// ISO8601 format. + /// the value indicating whether this alert + /// rule is migrated. + public MetricAlertResourcePatch(IDictionary tags = default(IDictionary), string description = default(string), int? severity = default(int?), bool? enabled = default(bool?), IList scopes = default(IList), System.TimeSpan? evaluationFrequency = default(System.TimeSpan?), System.TimeSpan? windowSize = default(System.TimeSpan?), string targetResourceType = default(string), string targetResourceRegion = default(string), MetricAlertCriteria criteria = default(MetricAlertCriteria), bool? autoMitigate = default(bool?), IList actions = default(IList), System.DateTime? lastUpdatedTime = default(System.DateTime?), bool? isMigrated = default(bool?)) + { + Tags = tags; + Description = description; + Severity = severity; + Enabled = enabled; + Scopes = scopes; + EvaluationFrequency = evaluationFrequency; + WindowSize = windowSize; + TargetResourceType = targetResourceType; + TargetResourceRegion = targetResourceRegion; + Criteria = criteria; + AutoMitigate = autoMitigate; + Actions = actions; + LastUpdatedTime = lastUpdatedTime; + IsMigrated = isMigrated; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the description of the metric alert that will be + /// included in the alert email. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets alert severity {0, 1, 2, 3, 4} + /// + [JsonProperty(PropertyName = "properties.severity")] + public int? Severity { get; set; } + + /// + /// Gets or sets the flag that indicates whether the metric alert is + /// enabled. + /// + [JsonProperty(PropertyName = "properties.enabled")] + public bool? Enabled { get; set; } + + /// + /// Gets or sets the list of resource id's that this metric alert is + /// scoped to. + /// + [JsonProperty(PropertyName = "properties.scopes")] + public IList Scopes { get; set; } + + /// + /// Gets or sets how often the metric alert is evaluated represented in + /// ISO 8601 duration format. + /// + [JsonProperty(PropertyName = "properties.evaluationFrequency")] + public System.TimeSpan? EvaluationFrequency { get; set; } + + /// + /// Gets or sets the period of time (in ISO 8601 duration format) that + /// is used to monitor alert activity based on the threshold. + /// + [JsonProperty(PropertyName = "properties.windowSize")] + public System.TimeSpan? WindowSize { get; set; } + + /// + /// Gets or sets the resource type of the target resource(s) on which + /// the alert is created/updated. Mandatory for + /// MultipleResourceMultipleMetricCriteria. + /// + [JsonProperty(PropertyName = "properties.targetResourceType")] + public string TargetResourceType { get; set; } + + /// + /// Gets or sets the region of the target resource(s) on which the + /// alert is created/updated. Mandatory for + /// MultipleResourceMultipleMetricCriteria. + /// + [JsonProperty(PropertyName = "properties.targetResourceRegion")] + public string TargetResourceRegion { get; set; } + + /// + /// Gets or sets defines the specific alert criteria information. + /// + [JsonProperty(PropertyName = "properties.criteria")] + public MetricAlertCriteria Criteria { get; set; } + + /// + /// Gets or sets the flag that indicates whether the alert should be + /// auto resolved or not. The default is true. + /// + [JsonProperty(PropertyName = "properties.autoMitigate")] + public bool? AutoMitigate { get; set; } + + /// + /// Gets or sets the array of actions that are performed when the alert + /// rule becomes active, and when an alert condition is resolved. + /// + [JsonProperty(PropertyName = "properties.actions")] + public IList Actions { get; set; } + + /// + /// Gets last time the rule was updated in ISO8601 format. + /// + [JsonProperty(PropertyName = "properties.lastUpdatedTime")] + public System.DateTime? LastUpdatedTime { get; private set; } + + /// + /// Gets the value indicating whether this alert rule is migrated. + /// + [JsonProperty(PropertyName = "properties.isMigrated")] + public bool? IsMigrated { get; private set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs new file mode 100644 index 000000000000..bc38badfd4b5 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertSingleResourceMultipleMetricCriteria.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies the metric alert criteria for a single resource that has + /// multiple metric criteria. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria")] + public partial class MetricAlertSingleResourceMultipleMetricCriteria : MetricAlertCriteria + { + /// + /// Initializes a new instance of the + /// MetricAlertSingleResourceMultipleMetricCriteria class. + /// + public MetricAlertSingleResourceMultipleMetricCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// MetricAlertSingleResourceMultipleMetricCriteria class. + /// + /// Unmatched properties from the + /// message are deserialized this collection + /// The list of metric criteria for this 'all of' + /// operation. + public MetricAlertSingleResourceMultipleMetricCriteria(IDictionary additionalProperties = default(IDictionary), IList allOf = default(IList)) + : base(additionalProperties) + { + AllOf = allOf; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of metric criteria for this 'all of' + /// operation. + /// + [JsonProperty(PropertyName = "allOf")] + public IList AllOf { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatus.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatus.cs new file mode 100644 index 000000000000..f09809a7535e --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatus.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// An alert status. + /// + public partial class MetricAlertStatus + { + /// + /// Initializes a new instance of the MetricAlertStatus class. + /// + public MetricAlertStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertStatus class. + /// + /// The status name. + /// The alert rule arm id. + /// The extended resource type name. + /// The alert status properties of the metric + /// alert status. + public MetricAlertStatus(string name = default(string), string id = default(string), string type = default(string), MetricAlertStatusProperties properties = default(MetricAlertStatusProperties)) + { + Name = name; + Id = id; + Type = type; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the status name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the alert rule arm id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the extended resource type name. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the alert status properties of the metric alert + /// status. + /// + [JsonProperty(PropertyName = "properties")] + public MetricAlertStatusProperties Properties { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatusCollection.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatusCollection.cs new file mode 100644 index 000000000000..461d2b441d0b --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatusCollection.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a collection of alert rule resources. + /// + public partial class MetricAlertStatusCollection + { + /// + /// Initializes a new instance of the MetricAlertStatusCollection + /// class. + /// + public MetricAlertStatusCollection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertStatusCollection + /// class. + /// + /// the values for the alert rule + /// resources. + public MetricAlertStatusCollection(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the values for the alert rule resources. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatusProperties.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatusProperties.cs new file mode 100644 index 000000000000..ba3dedbad37d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAlertStatusProperties.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An alert status properties. + /// + public partial class MetricAlertStatusProperties + { + /// + /// Initializes a new instance of the MetricAlertStatusProperties + /// class. + /// + public MetricAlertStatusProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAlertStatusProperties + /// class. + /// + /// An object describing the type of the + /// dimensions. + /// status value + /// UTC time when the status was + /// checked. + public MetricAlertStatusProperties(IDictionary dimensions = default(IDictionary), string status = default(string), System.DateTime? timestamp = default(System.DateTime?)) + { + Dimensions = dimensions; + Status = status; + Timestamp = timestamp; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets an object describing the type of the dimensions. + /// + [JsonProperty(PropertyName = "dimensions")] + public IDictionary Dimensions { get; set; } + + /// + /// Gets or sets status value + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets UTC time when the status was checked. + /// + [JsonProperty(PropertyName = "timestamp")] + public System.DateTime? Timestamp { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAvailability.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAvailability.cs new file mode 100644 index 000000000000..c60ef65fd5e1 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricAvailability.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metric availability specifies the time grain (aggregation interval or + /// frequency) and the retention period for that time grain. + /// + public partial class MetricAvailability + { + /// + /// Initializes a new instance of the MetricAvailability class. + /// + public MetricAvailability() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricAvailability class. + /// + /// the time grain specifies the aggregation + /// interval for the metric. Expressed as a duration 'PT1M', 'P1D', + /// etc. + /// the retention period for the metric at the + /// specified timegrain. Expressed as a duration 'PT1M', 'P1D', + /// etc. + public MetricAvailability(System.TimeSpan? timeGrain = default(System.TimeSpan?), System.TimeSpan? retention = default(System.TimeSpan?)) + { + TimeGrain = timeGrain; + Retention = retention; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the time grain specifies the aggregation interval for + /// the metric. Expressed as a duration 'PT1M', 'P1D', etc. + /// + [JsonProperty(PropertyName = "timeGrain")] + public System.TimeSpan? TimeGrain { get; set; } + + /// + /// Gets or sets the retention period for the metric at the specified + /// timegrain. Expressed as a duration 'PT1M', 'P1D', etc. + /// + [JsonProperty(PropertyName = "retention")] + public System.TimeSpan? Retention { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricClass.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricClass.cs new file mode 100644 index 000000000000..378581566094 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricClass.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for MetricClass. + /// + public static class MetricClass + { + public const string Availability = "Availability"; + public const string Transactions = "Transactions"; + public const string Errors = "Errors"; + public const string Latency = "Latency"; + public const string Saturation = "Saturation"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricCriteria.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricCriteria.cs new file mode 100644 index 000000000000..99e60d8084f0 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricCriteria.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Criterion to filter metrics. + /// + [Newtonsoft.Json.JsonObject("StaticThresholdCriterion")] + public partial class MetricCriteria : MultiMetricCriteria + { + /// + /// Initializes a new instance of the MetricCriteria class. + /// + public MetricCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricCriteria class. + /// + /// Name of the criteria. + /// Name of the metric. + /// the criteria time aggregation types. + /// Possible values include: 'Average', 'Count', 'Minimum', 'Maximum', + /// 'Total' + /// the criteria operator. Possible + /// values include: 'Equals', 'GreaterThan', 'GreaterThanOrEqual', + /// 'LessThan', 'LessThanOrEqual' + /// the criteria threshold value that activates + /// the alert. + /// Unmatched properties from the + /// message are deserialized this collection + /// Namespace of the metric. + /// List of dimension conditions. + /// Allows creating an alert rule on + /// a custom metric that isn't yet emitted, by causing the metric + /// validation to be skipped. + public MetricCriteria(string name, string metricName, string timeAggregation, string operatorProperty, double threshold, IDictionary additionalProperties = default(IDictionary), string metricNamespace = default(string), IList dimensions = default(IList), bool? skipMetricValidation = default(bool?)) + : base(name, metricName, timeAggregation, additionalProperties, metricNamespace, dimensions, skipMetricValidation) + { + OperatorProperty = operatorProperty; + Threshold = threshold; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the criteria operator. Possible values include: + /// 'Equals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + /// 'LessThanOrEqual' + /// + [JsonProperty(PropertyName = "operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets the criteria threshold value that activates the alert. + /// + [JsonProperty(PropertyName = "threshold")] + public double Threshold { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricDefinition.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricDefinition.cs new file mode 100644 index 000000000000..84d38c86e0b4 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricDefinition.cs @@ -0,0 +1,201 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Metric definition class specifies the metadata for a metric. + /// + public partial class MetricDefinition + { + /// + /// Initializes a new instance of the MetricDefinition class. + /// + public MetricDefinition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricDefinition class. + /// + /// Flag to indicate whether the + /// dimension is required. + /// the resource identifier of the resource + /// that emitted the metric. + /// the namespace the metric belongs + /// to. + /// the name and the display name of the metric, + /// i.e. it is a localizable string. + /// Detailed description of this + /// metric. + /// Custom category name for this + /// metric. + /// The class of the metric. Possible values + /// include: 'Availability', 'Transactions', 'Errors', 'Latency', + /// 'Saturation' + /// The unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'CountPerSecond', 'BytesPerSecond', + /// 'Percent', 'MilliSeconds', 'ByteSeconds', 'Unspecified', 'Cores', + /// 'MilliCores', 'NanoCores', 'BitsPerSecond' + /// the primary aggregation type + /// value defining how to use the values for display. Possible values + /// include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', + /// 'Total' + /// the collection of what + /// aggregation types are supported. + /// the collection of what + /// aggregation intervals are available to be queried. + /// the resource identifier of the metric + /// definition. + /// the name and the display name of the + /// dimension, i.e. it is a localizable string. + public MetricDefinition(bool? isDimensionRequired = default(bool?), string resourceId = default(string), string namespaceProperty = default(string), LocalizableString name = default(LocalizableString), string displayDescription = default(string), string category = default(string), string metricClass = default(string), string unit = default(string), AggregationType? primaryAggregationType = default(AggregationType?), IList supportedAggregationTypes = default(IList), IList metricAvailabilities = default(IList), string id = default(string), IList dimensions = default(IList)) + { + IsDimensionRequired = isDimensionRequired; + ResourceId = resourceId; + NamespaceProperty = namespaceProperty; + Name = name; + DisplayDescription = displayDescription; + Category = category; + MetricClass = metricClass; + Unit = unit; + PrimaryAggregationType = primaryAggregationType; + SupportedAggregationTypes = supportedAggregationTypes; + MetricAvailabilities = metricAvailabilities; + Id = id; + Dimensions = dimensions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets flag to indicate whether the dimension is required. + /// + [JsonProperty(PropertyName = "isDimensionRequired")] + public bool? IsDimensionRequired { get; set; } + + /// + /// Gets or sets the resource identifier of the resource that emitted + /// the metric. + /// + [JsonProperty(PropertyName = "resourceId")] + public string ResourceId { get; set; } + + /// + /// Gets or sets the namespace the metric belongs to. + /// + [JsonProperty(PropertyName = "namespace")] + public string NamespaceProperty { get; set; } + + /// + /// Gets or sets the name and the display name of the metric, i.e. it + /// is a localizable string. + /// + [JsonProperty(PropertyName = "name")] + public LocalizableString Name { get; set; } + + /// + /// Gets or sets detailed description of this metric. + /// + [JsonProperty(PropertyName = "displayDescription")] + public string DisplayDescription { get; set; } + + /// + /// Gets or sets custom category name for this metric. + /// + [JsonProperty(PropertyName = "category")] + public string Category { get; set; } + + /// + /// Gets or sets the class of the metric. Possible values include: + /// 'Availability', 'Transactions', 'Errors', 'Latency', 'Saturation' + /// + [JsonProperty(PropertyName = "metricClass")] + public string MetricClass { get; set; } + + /// + /// Gets or sets the unit of the metric. Possible values include: + /// 'Count', 'Bytes', 'Seconds', 'CountPerSecond', 'BytesPerSecond', + /// 'Percent', 'MilliSeconds', 'ByteSeconds', 'Unspecified', 'Cores', + /// 'MilliCores', 'NanoCores', 'BitsPerSecond' + /// + [JsonProperty(PropertyName = "unit")] + public string Unit { get; set; } + + /// + /// Gets or sets the primary aggregation type value defining how to use + /// the values for display. Possible values include: 'None', 'Average', + /// 'Count', 'Minimum', 'Maximum', 'Total' + /// + [JsonProperty(PropertyName = "primaryAggregationType")] + public AggregationType? PrimaryAggregationType { get; set; } + + /// + /// Gets or sets the collection of what aggregation types are + /// supported. + /// + [JsonProperty(PropertyName = "supportedAggregationTypes")] + public IList SupportedAggregationTypes { get; set; } + + /// + /// Gets or sets the collection of what aggregation intervals are + /// available to be queried. + /// + [JsonProperty(PropertyName = "metricAvailabilities")] + public IList MetricAvailabilities { get; set; } + + /// + /// Gets or sets the resource identifier of the metric definition. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the name and the display name of the dimension, i.e. + /// it is a localizable string. + /// + [JsonProperty(PropertyName = "dimensions")] + public IList Dimensions { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name != null) + { + Name.Validate(); + } + if (Dimensions != null) + { + foreach (var element in Dimensions) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricDimension.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricDimension.cs new file mode 100644 index 000000000000..89e83546e09f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricDimension.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies a metric dimension. + /// + public partial class MetricDimension + { + /// + /// Initializes a new instance of the MetricDimension class. + /// + public MetricDimension() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricDimension class. + /// + /// Name of the dimension. + /// the dimension operator. Only + /// 'Include' and 'Exclude' are supported + /// list of dimension values. + public MetricDimension(string name, string operatorProperty, IList values) + { + Name = name; + OperatorProperty = operatorProperty; + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the dimension. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the dimension operator. Only 'Include' and 'Exclude' + /// are supported + /// + [JsonProperty(PropertyName = "operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets list of dimension values. + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + if (Values == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Values"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricNamespace.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricNamespace.cs new file mode 100644 index 000000000000..4cfc95c792a5 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricNamespace.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metric namespace class specifies the metadata for a metric namespace. + /// + public partial class MetricNamespace + { + /// + /// Initializes a new instance of the MetricNamespace class. + /// + public MetricNamespace() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricNamespace class. + /// + /// The ID of the metric namespace. + /// The type of the namespace. + /// The escaped name of the namespace. + /// Kind of namespace. Possible values + /// include: 'Platform', 'Custom', 'Qos' + /// Properties which include the fully + /// qualified namespace name. + public MetricNamespace(string id = default(string), string type = default(string), string name = default(string), string classification = default(string), MetricNamespaceName properties = default(MetricNamespaceName)) + { + Id = id; + Type = type; + Name = name; + Classification = classification; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ID of the metric namespace. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the type of the namespace. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the escaped name of the namespace. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets kind of namespace. Possible values include: + /// 'Platform', 'Custom', 'Qos' + /// + [JsonProperty(PropertyName = "classification")] + public string Classification { get; set; } + + /// + /// Gets or sets properties which include the fully qualified namespace + /// name. + /// + [JsonProperty(PropertyName = "properties")] + public MetricNamespaceName Properties { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricNamespaceName.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricNamespaceName.cs new file mode 100644 index 000000000000..1415eb1300a4 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricNamespaceName.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The fully qualified metric namespace name. + /// + public partial class MetricNamespaceName + { + /// + /// Initializes a new instance of the MetricNamespaceName class. + /// + public MetricNamespaceName() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricNamespaceName class. + /// + /// The metric namespace + /// name. + public MetricNamespaceName(string metricNamespaceNameProperty = default(string)) + { + MetricNamespaceNameProperty = metricNamespaceNameProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the metric namespace name. + /// + [JsonProperty(PropertyName = "metricNamespaceName")] + public string MetricNamespaceNameProperty { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricSettings.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricSettings.cs new file mode 100644 index 000000000000..bf7657b2a3b8 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricSettings.cs @@ -0,0 +1,98 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Part of MultiTenantDiagnosticSettings. Specifies the settings for a + /// particular metric. + /// + public partial class MetricSettings + { + /// + /// Initializes a new instance of the MetricSettings class. + /// + public MetricSettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricSettings class. + /// + /// a value indicating whether this category is + /// enabled. + /// the timegrain of the metric in ISO8601 + /// format. + /// Name of a Diagnostic Metric category for a + /// resource type this setting is applied to. To obtain the list of + /// Diagnostic metric categories for a resource, first perform a GET + /// diagnostic settings operation. + /// the retention policy for this + /// category. + public MetricSettings(bool enabled, System.TimeSpan? timeGrain = default(System.TimeSpan?), string category = default(string), RetentionPolicy retentionPolicy = default(RetentionPolicy)) + { + TimeGrain = timeGrain; + Category = category; + Enabled = enabled; + RetentionPolicy = retentionPolicy; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the timegrain of the metric in ISO8601 format. + /// + [JsonProperty(PropertyName = "timeGrain")] + public System.TimeSpan? TimeGrain { get; set; } + + /// + /// Gets or sets name of a Diagnostic Metric category for a resource + /// type this setting is applied to. To obtain the list of Diagnostic + /// metric categories for a resource, first perform a GET diagnostic + /// settings operation. + /// + [JsonProperty(PropertyName = "category")] + public string Category { get; set; } + + /// + /// Gets or sets a value indicating whether this category is enabled. + /// + [JsonProperty(PropertyName = "enabled")] + public bool Enabled { get; set; } + + /// + /// Gets or sets the retention policy for this category. + /// + [JsonProperty(PropertyName = "retentionPolicy")] + public RetentionPolicy RetentionPolicy { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (RetentionPolicy != null) + { + RetentionPolicy.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricSingleDimension.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricSingleDimension.cs new file mode 100644 index 000000000000..b80789586206 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricSingleDimension.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The metric dimension name and value. + /// + public partial class MetricSingleDimension + { + /// + /// Initializes a new instance of the MetricSingleDimension class. + /// + public MetricSingleDimension() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricSingleDimension class. + /// + /// Name of the dimension. + /// Value of the dimension. + public MetricSingleDimension(string name, string value) + { + Name = name; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the dimension. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets value of the dimension. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricStatisticType.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricStatisticType.cs new file mode 100644 index 000000000000..241b24be5fe9 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricStatisticType.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for MetricStatisticType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum MetricStatisticType + { + [EnumMember(Value = "Average")] + Average, + [EnumMember(Value = "Min")] + Min, + [EnumMember(Value = "Max")] + Max, + [EnumMember(Value = "Sum")] + Sum, + [EnumMember(Value = "Count")] + Count + } + internal static class MetricStatisticTypeEnumExtension + { + internal static string ToSerializedValue(this MetricStatisticType? value) + { + return value == null ? null : ((MetricStatisticType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this MetricStatisticType value) + { + switch( value ) + { + case MetricStatisticType.Average: + return "Average"; + case MetricStatisticType.Min: + return "Min"; + case MetricStatisticType.Max: + return "Max"; + case MetricStatisticType.Sum: + return "Sum"; + case MetricStatisticType.Count: + return "Count"; + } + return null; + } + + internal static MetricStatisticType? ParseMetricStatisticType(this string value) + { + switch( value ) + { + case "Average": + return MetricStatisticType.Average; + case "Min": + return MetricStatisticType.Min; + case "Max": + return MetricStatisticType.Max; + case "Sum": + return MetricStatisticType.Sum; + case "Count": + return MetricStatisticType.Count; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricTrigger.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricTrigger.cs new file mode 100644 index 000000000000..dc19e4db4a29 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricTrigger.cs @@ -0,0 +1,208 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The trigger that results in a scaling action. + /// + public partial class MetricTrigger + { + /// + /// Initializes a new instance of the MetricTrigger class. + /// + public MetricTrigger() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricTrigger class. + /// + /// the name of the metric that defines what + /// the rule monitors. + /// the resource identifier of the + /// resource the rule monitors. + /// the granularity of metrics the rule + /// monitors. Must be one of the predefined values returned from metric + /// definitions for the metric. Must be between 12 hours and 1 + /// minute. + /// the metric statistic type. How the metrics + /// from multiple instances are combined. Possible values include: + /// 'Average', 'Min', 'Max', 'Sum', 'Count' + /// the range of time in which instance data + /// is collected. This value must be greater than the delay in metric + /// collection, which can vary from resource-to-resource. Must be + /// between 12 hours and 5 minutes. + /// time aggregation type. How the data + /// that is collected should be combined over time. The default value + /// is Average. Possible values include: 'Average', 'Minimum', + /// 'Maximum', 'Total', 'Count', 'Last' + /// the operator that is used to compare + /// the metric data and the threshold. Possible values include: + /// 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', + /// 'LessThan', 'LessThanOrEqual' + /// the threshold of the metric that triggers + /// the scale action. + /// the namespace of the metric that + /// defines what the rule monitors. + /// the location of the resource + /// the rule monitors. + /// List of dimension conditions. For example: + /// [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + /// a value indicating whether metric + /// should divide per instance. + public MetricTrigger(string metricName, string metricResourceUri, System.TimeSpan timeGrain, MetricStatisticType statistic, System.TimeSpan timeWindow, TimeAggregationType timeAggregation, ComparisonOperationType operatorProperty, double threshold, string metricNamespace = default(string), string metricResourceLocation = default(string), IList dimensions = default(IList), bool? dividePerInstance = default(bool?)) + { + MetricName = metricName; + MetricNamespace = metricNamespace; + MetricResourceUri = metricResourceUri; + MetricResourceLocation = metricResourceLocation; + TimeGrain = timeGrain; + Statistic = statistic; + TimeWindow = timeWindow; + TimeAggregation = timeAggregation; + OperatorProperty = operatorProperty; + Threshold = threshold; + Dimensions = dimensions; + DividePerInstance = dividePerInstance; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the metric that defines what the rule + /// monitors. + /// + [JsonProperty(PropertyName = "metricName")] + public string MetricName { get; set; } + + /// + /// Gets or sets the namespace of the metric that defines what the rule + /// monitors. + /// + [JsonProperty(PropertyName = "metricNamespace")] + public string MetricNamespace { get; set; } + + /// + /// Gets or sets the resource identifier of the resource the rule + /// monitors. + /// + [JsonProperty(PropertyName = "metricResourceUri")] + public string MetricResourceUri { get; set; } + + /// + /// Gets or sets the location of the resource the rule monitors. + /// + [JsonProperty(PropertyName = "metricResourceLocation")] + public string MetricResourceLocation { get; set; } + + /// + /// Gets or sets the granularity of metrics the rule monitors. Must be + /// one of the predefined values returned from metric definitions for + /// the metric. Must be between 12 hours and 1 minute. + /// + [JsonProperty(PropertyName = "timeGrain")] + public System.TimeSpan TimeGrain { get; set; } + + /// + /// Gets or sets the metric statistic type. How the metrics from + /// multiple instances are combined. Possible values include: + /// 'Average', 'Min', 'Max', 'Sum', 'Count' + /// + [JsonProperty(PropertyName = "statistic")] + public MetricStatisticType Statistic { get; set; } + + /// + /// Gets or sets the range of time in which instance data is collected. + /// This value must be greater than the delay in metric collection, + /// which can vary from resource-to-resource. Must be between 12 hours + /// and 5 minutes. + /// + [JsonProperty(PropertyName = "timeWindow")] + public System.TimeSpan TimeWindow { get; set; } + + /// + /// Gets or sets time aggregation type. How the data that is collected + /// should be combined over time. The default value is Average. + /// Possible values include: 'Average', 'Minimum', 'Maximum', 'Total', + /// 'Count', 'Last' + /// + [JsonProperty(PropertyName = "timeAggregation")] + public TimeAggregationType TimeAggregation { get; set; } + + /// + /// Gets or sets the operator that is used to compare the metric data + /// and the threshold. Possible values include: 'Equals', 'NotEquals', + /// 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + /// + [JsonProperty(PropertyName = "operator")] + public ComparisonOperationType OperatorProperty { get; set; } + + /// + /// Gets or sets the threshold of the metric that triggers the scale + /// action. + /// + [JsonProperty(PropertyName = "threshold")] + public double Threshold { get; set; } + + /// + /// Gets or sets list of dimension conditions. For example: + /// [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + /// + [JsonProperty(PropertyName = "dimensions")] + public IList Dimensions { get; set; } + + /// + /// Gets or sets a value indicating whether metric should divide per + /// instance. + /// + [JsonProperty(PropertyName = "dividePerInstance")] + public bool? DividePerInstance { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (MetricName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MetricName"); + } + if (MetricResourceUri == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MetricResourceUri"); + } + if (Dimensions != null) + { + foreach (var element in Dimensions) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricUnit.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricUnit.cs new file mode 100644 index 000000000000..b1233d95500c --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricUnit.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for MetricUnit. + /// + public static class MetricUnit + { + public const string Count = "Count"; + public const string Bytes = "Bytes"; + public const string Seconds = "Seconds"; + public const string CountPerSecond = "CountPerSecond"; + public const string BytesPerSecond = "BytesPerSecond"; + public const string Percent = "Percent"; + public const string MilliSeconds = "MilliSeconds"; + public const string ByteSeconds = "ByteSeconds"; + public const string Unspecified = "Unspecified"; + public const string Cores = "Cores"; + public const string MilliCores = "MilliCores"; + public const string NanoCores = "NanoCores"; + public const string BitsPerSecond = "BitsPerSecond"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricValue.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricValue.cs new file mode 100644 index 000000000000..01180a7f2634 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MetricValue.cs @@ -0,0 +1,107 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a metric value. + /// + public partial class MetricValue + { + /// + /// Initializes a new instance of the MetricValue class. + /// + public MetricValue() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MetricValue class. + /// + /// the timestamp for the metric value in ISO + /// 8601 format. + /// the average value in the time range. + /// the least value in the time range. + /// the greatest value in the time range. + /// the sum of all of the values in the time + /// range. + /// the number of samples in the time range. Can be + /// used to determine the number of values that contributed to the + /// average value. + public MetricValue(System.DateTime timeStamp, double? average = default(double?), double? minimum = default(double?), double? maximum = default(double?), double? total = default(double?), double? count = default(double?)) + { + TimeStamp = timeStamp; + Average = average; + Minimum = minimum; + Maximum = maximum; + Total = total; + Count = count; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the timestamp for the metric value in ISO 8601 format. + /// + [JsonProperty(PropertyName = "timeStamp")] + public System.DateTime TimeStamp { get; set; } + + /// + /// Gets or sets the average value in the time range. + /// + [JsonProperty(PropertyName = "average")] + public double? Average { get; set; } + + /// + /// Gets or sets the least value in the time range. + /// + [JsonProperty(PropertyName = "minimum")] + public double? Minimum { get; set; } + + /// + /// Gets or sets the greatest value in the time range. + /// + [JsonProperty(PropertyName = "maximum")] + public double? Maximum { get; set; } + + /// + /// Gets or sets the sum of all of the values in the time range. + /// + [JsonProperty(PropertyName = "total")] + public double? Total { get; set; } + + /// + /// Gets or sets the number of samples in the time range. Can be used + /// to determine the number of values that contributed to the average + /// value. + /// + [JsonProperty(PropertyName = "count")] + public double? Count { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/MultiMetricCriteria.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MultiMetricCriteria.cs new file mode 100644 index 000000000000..ed17c02e18d6 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/MultiMetricCriteria.cs @@ -0,0 +1,142 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The types of conditions for a multi resource alert. + /// + [Newtonsoft.Json.JsonObject("MultiMetricCriteria")] + public partial class MultiMetricCriteria + { + /// + /// Initializes a new instance of the MultiMetricCriteria class. + /// + public MultiMetricCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MultiMetricCriteria class. + /// + /// Name of the criteria. + /// Name of the metric. + /// the criteria time aggregation types. + /// Possible values include: 'Average', 'Count', 'Minimum', 'Maximum', + /// 'Total' + /// Unmatched properties from the + /// message are deserialized this collection + /// Namespace of the metric. + /// List of dimension conditions. + /// Allows creating an alert rule on + /// a custom metric that isn't yet emitted, by causing the metric + /// validation to be skipped. + public MultiMetricCriteria(string name, string metricName, string timeAggregation, IDictionary additionalProperties = default(IDictionary), string metricNamespace = default(string), IList dimensions = default(IList), bool? skipMetricValidation = default(bool?)) + { + AdditionalProperties = additionalProperties; + Name = name; + MetricName = metricName; + MetricNamespace = metricNamespace; + TimeAggregation = timeAggregation; + Dimensions = dimensions; + SkipMetricValidation = skipMetricValidation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets unmatched properties from the message are deserialized + /// this collection + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Gets or sets name of the criteria. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets name of the metric. + /// + [JsonProperty(PropertyName = "metricName")] + public string MetricName { get; set; } + + /// + /// Gets or sets namespace of the metric. + /// + [JsonProperty(PropertyName = "metricNamespace")] + public string MetricNamespace { get; set; } + + /// + /// Gets or sets the criteria time aggregation types. Possible values + /// include: 'Average', 'Count', 'Minimum', 'Maximum', 'Total' + /// + [JsonProperty(PropertyName = "timeAggregation")] + public string TimeAggregation { get; set; } + + /// + /// Gets or sets list of dimension conditions. + /// + [JsonProperty(PropertyName = "dimensions")] + public IList Dimensions { get; set; } + + /// + /// Gets or sets allows creating an alert rule on a custom metric that + /// isn't yet emitted, by causing the metric validation to be skipped. + /// + [JsonProperty(PropertyName = "skipMetricValidation")] + public bool? SkipMetricValidation { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (MetricName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MetricName"); + } + if (TimeAggregation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TimeAggregation"); + } + if (Dimensions != null) + { + foreach (var element in Dimensions) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/NamespaceClassification.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/NamespaceClassification.cs new file mode 100644 index 000000000000..cf9e86b28491 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/NamespaceClassification.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for NamespaceClassification. + /// + public static class NamespaceClassification + { + public const string Platform = "Platform"; + public const string Custom = "Custom"; + public const string Qos = "Qos"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/OperationStatus.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/OperationStatus.cs new file mode 100644 index 000000000000..083acf983694 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/OperationStatus.cs @@ -0,0 +1,94 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The status of operation. + /// + public partial class OperationStatus + { + /// + /// Initializes a new instance of the OperationStatus class. + /// + public OperationStatus() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationStatus class. + /// + /// The operation Id. + /// The operation name. + /// Start time of the job in standard ISO8601 + /// format. + /// End time of the job in standard ISO8601 + /// format. + /// The status of the operation. + /// The error detail of the operation if + /// any. + public OperationStatus(string id = default(string), string name = default(string), System.DateTime? startTime = default(System.DateTime?), System.DateTime? endTime = default(System.DateTime?), string status = default(string), ErrorResponseCommon error = default(ErrorResponseCommon)) + { + Id = id; + Name = name; + StartTime = startTime; + EndTime = endTime; + Status = status; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the operation Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the operation name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets start time of the job in standard ISO8601 format. + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; set; } + + /// + /// Gets or sets end time of the job in standard ISO8601 format. + /// + [JsonProperty(PropertyName = "endTime")] + public System.DateTime? EndTime { get; set; } + + /// + /// Gets or sets the status of the operation. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the error detail of the operation if any. + /// + [JsonProperty(PropertyName = "error")] + public ErrorResponseCommon Error { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/OperatorModel.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/OperatorModel.cs new file mode 100644 index 000000000000..f17a6d3c7801 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/OperatorModel.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for OperatorModel. + /// + public static class OperatorModel + { + public const string Equals = "Equals"; + public const string GreaterThan = "GreaterThan"; + public const string GreaterThanOrEqual = "GreaterThanOrEqual"; + public const string LessThan = "LessThan"; + public const string LessThanOrEqual = "LessThanOrEqual"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/Page.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Page.cs new file mode 100644 index 000000000000..f13b6312d35f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Page.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/Page1.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Page1.cs new file mode 100644 index 000000000000..8eb5b9de7c3e --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Page1.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page1 : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateEndpointConnection.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateEndpointConnection.cs new file mode 100644 index 000000000000..92815fd0af43 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateEndpointConnection.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A private endpoint connection + /// + [Rest.Serialization.JsonTransformation] + public partial class PrivateEndpointConnection : ProxyResource + { + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + public PrivateEndpointConnection() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointConnection class. + /// + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Private endpoint which the connection + /// belongs to. + /// Connection state of + /// the private endpoint connection. + /// State of the private endpoint + /// connection. + public PrivateEndpointConnection(string id = default(string), string name = default(string), string type = default(string), PrivateEndpointProperty privateEndpoint = default(PrivateEndpointProperty), PrivateLinkServiceConnectionStateProperty privateLinkServiceConnectionState = default(PrivateLinkServiceConnectionStateProperty), string provisioningState = default(string)) + : base(id, name, type) + { + PrivateEndpoint = privateEndpoint; + PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets private endpoint which the connection belongs to. + /// + [JsonProperty(PropertyName = "properties.privateEndpoint")] + public PrivateEndpointProperty PrivateEndpoint { get; set; } + + /// + /// Gets or sets connection state of the private endpoint connection. + /// + [JsonProperty(PropertyName = "properties.privateLinkServiceConnectionState")] + public PrivateLinkServiceConnectionStateProperty PrivateLinkServiceConnectionState { get; set; } + + /// + /// Gets state of the private endpoint connection. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (PrivateLinkServiceConnectionState != null) + { + PrivateLinkServiceConnectionState.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateEndpointProperty.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateEndpointProperty.cs new file mode 100644 index 000000000000..58ffe77bb549 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateEndpointProperty.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Private endpoint which the connection belongs to. + /// + public partial class PrivateEndpointProperty + { + /// + /// Initializes a new instance of the PrivateEndpointProperty class. + /// + public PrivateEndpointProperty() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateEndpointProperty class. + /// + /// Resource id of the private endpoint. + public PrivateEndpointProperty(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource id of the private endpoint. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkResource.cs new file mode 100644 index 000000000000..7c2dae65de48 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkResource.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A private link resource + /// + [Rest.Serialization.JsonTransformation] + public partial class PrivateLinkResource : ProxyResource + { + /// + /// Initializes a new instance of the PrivateLinkResource class. + /// + public PrivateLinkResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkResource class. + /// + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// The private link resource group id. + /// The private link resource required + /// member names. + public PrivateLinkResource(string id = default(string), string name = default(string), string type = default(string), string groupId = default(string), IList requiredMembers = default(IList)) + : base(id, name, type) + { + GroupId = groupId; + RequiredMembers = requiredMembers; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the private link resource group id. + /// + [JsonProperty(PropertyName = "properties.groupId")] + public string GroupId { get; private set; } + + /// + /// Gets the private link resource required member names. + /// + [JsonProperty(PropertyName = "properties.requiredMembers")] + public IList RequiredMembers { get; private set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkScopesResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkScopesResource.cs new file mode 100644 index 000000000000..ef895d380760 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkScopesResource.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An azure resource object + /// + public partial class PrivateLinkScopesResource : IResource + { + /// + /// Initializes a new instance of the PrivateLinkScopesResource class. + /// + public PrivateLinkScopesResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PrivateLinkScopesResource class. + /// + /// Resource location + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + public PrivateLinkScopesResource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets azure resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets azure resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets azure resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets resource location + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs new file mode 100644 index 000000000000..887acba7f23a --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/PrivateLinkServiceConnectionStateProperty.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// State of the private endpoint connection. + /// + public partial class PrivateLinkServiceConnectionStateProperty + { + /// + /// Initializes a new instance of the + /// PrivateLinkServiceConnectionStateProperty class. + /// + public PrivateLinkServiceConnectionStateProperty() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PrivateLinkServiceConnectionStateProperty class. + /// + /// The private link service connection + /// status. + /// The private link service connection + /// description. + /// The actions required for private link + /// service connection. + public PrivateLinkServiceConnectionStateProperty(string status, string description, string actionsRequired = default(string)) + { + Status = status; + Description = description; + ActionsRequired = actionsRequired; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the private link service connection status. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the private link service connection description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets the actions required for private link service connection. + /// + [JsonProperty(PropertyName = "actionsRequired")] + public string ActionsRequired { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Status == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Status"); + } + if (Description == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Description"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ProxyOnlyResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ProxyOnlyResource.cs new file mode 100644 index 000000000000..cd2757f49843 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ProxyOnlyResource.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A proxy only azure resource object + /// + public partial class ProxyOnlyResource : IResource + { + /// + /// Initializes a new instance of the ProxyOnlyResource class. + /// + public ProxyOnlyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyOnlyResource class. + /// + /// Azure resource Id + /// Azure resource name + /// Azure resource type + public ProxyOnlyResource(string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets azure resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets azure resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets azure resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ProxyResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ProxyResource.cs new file mode 100644 index 000000000000..18a5c4e49cde --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ProxyResource.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Linq; + + /// + /// An azure resource object + /// + public partial class ProxyResource : IResource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + /// Azure resource Id + /// Azure resource name + /// Azure resource type + public ProxyResource(string id = default(string), string name = default(string), string type = default(string)) + { + Id = id; + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets azure resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets azure resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets azure resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/Recurrence.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Recurrence.cs new file mode 100644 index 000000000000..040810a5ece6 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Recurrence.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The repeating times at which this profile begins. This element is not + /// used if the FixedDate element is used. + /// + public partial class Recurrence + { + /// + /// Initializes a new instance of the Recurrence class. + /// + public Recurrence() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Recurrence class. + /// + /// the recurrence frequency. How often the + /// schedule profile should take effect. This value must be Week, + /// meaning each week will have the same set of profiles. For example, + /// to set a daily schedule, set **schedule** to every day of the week. + /// The frequency property specifies that the schedule is repeated + /// weekly. Possible values include: 'None', 'Second', 'Minute', + /// 'Hour', 'Day', 'Week', 'Month', 'Year' + /// the scheduling constraints for when the + /// profile begins. + public Recurrence(RecurrenceFrequency frequency, RecurrentSchedule schedule) + { + Frequency = frequency; + Schedule = schedule; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the recurrence frequency. How often the schedule + /// profile should take effect. This value must be Week, meaning each + /// week will have the same set of profiles. For example, to set a + /// daily schedule, set **schedule** to every day of the week. The + /// frequency property specifies that the schedule is repeated weekly. + /// Possible values include: 'None', 'Second', 'Minute', 'Hour', 'Day', + /// 'Week', 'Month', 'Year' + /// + [JsonProperty(PropertyName = "frequency")] + public RecurrenceFrequency Frequency { get; set; } + + /// + /// Gets or sets the scheduling constraints for when the profile + /// begins. + /// + [JsonProperty(PropertyName = "schedule")] + public RecurrentSchedule Schedule { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Schedule == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Schedule"); + } + if (Schedule != null) + { + Schedule.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RecurrenceFrequency.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RecurrenceFrequency.cs new file mode 100644 index 000000000000..27b48299752a --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RecurrenceFrequency.cs @@ -0,0 +1,96 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for RecurrenceFrequency. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum RecurrenceFrequency + { + [EnumMember(Value = "None")] + None, + [EnumMember(Value = "Second")] + Second, + [EnumMember(Value = "Minute")] + Minute, + [EnumMember(Value = "Hour")] + Hour, + [EnumMember(Value = "Day")] + Day, + [EnumMember(Value = "Week")] + Week, + [EnumMember(Value = "Month")] + Month, + [EnumMember(Value = "Year")] + Year + } + internal static class RecurrenceFrequencyEnumExtension + { + internal static string ToSerializedValue(this RecurrenceFrequency? value) + { + return value == null ? null : ((RecurrenceFrequency)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this RecurrenceFrequency value) + { + switch( value ) + { + case RecurrenceFrequency.None: + return "None"; + case RecurrenceFrequency.Second: + return "Second"; + case RecurrenceFrequency.Minute: + return "Minute"; + case RecurrenceFrequency.Hour: + return "Hour"; + case RecurrenceFrequency.Day: + return "Day"; + case RecurrenceFrequency.Week: + return "Week"; + case RecurrenceFrequency.Month: + return "Month"; + case RecurrenceFrequency.Year: + return "Year"; + } + return null; + } + + internal static RecurrenceFrequency? ParseRecurrenceFrequency(this string value) + { + switch( value ) + { + case "None": + return RecurrenceFrequency.None; + case "Second": + return RecurrenceFrequency.Second; + case "Minute": + return RecurrenceFrequency.Minute; + case "Hour": + return RecurrenceFrequency.Hour; + case "Day": + return RecurrenceFrequency.Day; + case "Week": + return RecurrenceFrequency.Week; + case "Month": + return RecurrenceFrequency.Month; + case "Year": + return RecurrenceFrequency.Year; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RecurrentSchedule.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RecurrentSchedule.cs new file mode 100644 index 000000000000..5003472be503 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RecurrentSchedule.cs @@ -0,0 +1,194 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The scheduling constraints for when the profile begins. + /// + public partial class RecurrentSchedule + { + /// + /// Initializes a new instance of the RecurrentSchedule class. + /// + public RecurrentSchedule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RecurrentSchedule class. + /// + /// the timezone for the hours of the profile. + /// Some examples of valid time zones are: Dateline Standard Time, + /// UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific + /// Standard Time (Mexico), Pacific Standard Time, US Mountain Standard + /// Time, Mountain Standard Time (Mexico), Mountain Standard Time, + /// Central America Standard Time, Central Standard Time, Central + /// Standard Time (Mexico), Canada Central Standard Time, SA Pacific + /// Standard Time, Eastern Standard Time, US Eastern Standard Time, + /// Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard + /// Time, Central Brazilian Standard Time, SA Western Standard Time, + /// Pacific SA Standard Time, Newfoundland Standard Time, E. South + /// America Standard Time, Argentina Standard Time, SA Eastern Standard + /// Time, Greenland Standard Time, Montevideo Standard Time, Bahia + /// Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard + /// Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT + /// Standard Time, Greenwich Standard Time, W. Europe Standard Time, + /// Central Europe Standard Time, Romance Standard Time, Central + /// European Standard Time, W. Central Africa Standard Time, Namibia + /// Standard Time, Jordan Standard Time, GTB Standard Time, Middle East + /// Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe + /// Standard Time, South Africa Standard Time, FLE Standard Time, + /// Turkey Standard Time, Israel Standard Time, Kaliningrad Standard + /// Time, Libya Standard Time, Arabic Standard Time, Arab Standard + /// Time, Belarus Standard Time, Russian Standard Time, E. Africa + /// Standard Time, Iran Standard Time, Arabian Standard Time, + /// Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard + /// Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan + /// Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, + /// Pakistan Standard Time, India Standard Time, Sri Lanka Standard + /// Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh + /// Standard Time, N. Central Asia Standard Time, Myanmar Standard + /// Time, SE Asia Standard Time, North Asia Standard Time, China + /// Standard Time, North Asia East Standard Time, Singapore Standard + /// Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar + /// Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk + /// Standard Time, Cen. Australia Standard Time, AUS Central Standard + /// Time, E. Australia Standard Time, AUS Eastern Standard Time, West + /// Pacific Standard Time, Tasmania Standard Time, Magadan Standard + /// Time, Vladivostok Standard Time, Russia Time Zone 10, Central + /// Pacific Standard Time, Russia Time Zone 11, New Zealand Standard + /// Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga + /// Standard Time, Samoa Standard Time, Line Islands Standard + /// Time + /// the collection of days that the profile takes + /// effect on. Possible values are Sunday through Saturday. + /// A collection of hours that the profile takes + /// effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM + /// times are not supported). + /// A collection of minutes at which the profile + /// takes effect at. + public RecurrentSchedule(string timeZone, IList days, IList hours, IList minutes) + { + TimeZone = timeZone; + Days = days; + Hours = hours; + Minutes = minutes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the timezone for the hours of the profile. Some + /// examples of valid time zones are: Dateline Standard Time, UTC-11, + /// Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard + /// Time (Mexico), Pacific Standard Time, US Mountain Standard Time, + /// Mountain Standard Time (Mexico), Mountain Standard Time, Central + /// America Standard Time, Central Standard Time, Central Standard Time + /// (Mexico), Canada Central Standard Time, SA Pacific Standard Time, + /// Eastern Standard Time, US Eastern Standard Time, Venezuela Standard + /// Time, Paraguay Standard Time, Atlantic Standard Time, Central + /// Brazilian Standard Time, SA Western Standard Time, Pacific SA + /// Standard Time, Newfoundland Standard Time, E. South America + /// Standard Time, Argentina Standard Time, SA Eastern Standard Time, + /// Greenland Standard Time, Montevideo Standard Time, Bahia Standard + /// Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, + /// Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard + /// Time, Greenwich Standard Time, W. Europe Standard Time, Central + /// Europe Standard Time, Romance Standard Time, Central European + /// Standard Time, W. Central Africa Standard Time, Namibia Standard + /// Time, Jordan Standard Time, GTB Standard Time, Middle East Standard + /// Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard + /// Time, South Africa Standard Time, FLE Standard Time, Turkey + /// Standard Time, Israel Standard Time, Kaliningrad Standard Time, + /// Libya Standard Time, Arabic Standard Time, Arab Standard Time, + /// Belarus Standard Time, Russian Standard Time, E. Africa Standard + /// Time, Iran Standard Time, Arabian Standard Time, Azerbaijan + /// Standard Time, Russia Time Zone 3, Mauritius Standard Time, + /// Georgian Standard Time, Caucasus Standard Time, Afghanistan + /// Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, + /// Pakistan Standard Time, India Standard Time, Sri Lanka Standard + /// Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh + /// Standard Time, N. Central Asia Standard Time, Myanmar Standard + /// Time, SE Asia Standard Time, North Asia Standard Time, China + /// Standard Time, North Asia East Standard Time, Singapore Standard + /// Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar + /// Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk + /// Standard Time, Cen. Australia Standard Time, AUS Central Standard + /// Time, E. Australia Standard Time, AUS Eastern Standard Time, West + /// Pacific Standard Time, Tasmania Standard Time, Magadan Standard + /// Time, Vladivostok Standard Time, Russia Time Zone 10, Central + /// Pacific Standard Time, Russia Time Zone 11, New Zealand Standard + /// Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga + /// Standard Time, Samoa Standard Time, Line Islands Standard Time + /// + [JsonProperty(PropertyName = "timeZone")] + public string TimeZone { get; set; } + + /// + /// Gets or sets the collection of days that the profile takes effect + /// on. Possible values are Sunday through Saturday. + /// + [JsonProperty(PropertyName = "days")] + public IList Days { get; set; } + + /// + /// Gets or sets a collection of hours that the profile takes effect + /// on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times + /// are not supported). + /// + [JsonProperty(PropertyName = "hours")] + public IList Hours { get; set; } + + /// + /// Gets or sets a collection of minutes at which the profile takes + /// effect at. + /// + [JsonProperty(PropertyName = "minutes")] + public IList Minutes { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (TimeZone == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TimeZone"); + } + if (Days == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Days"); + } + if (Hours == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Hours"); + } + if (Minutes == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Minutes"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/Resource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Resource.cs new file mode 100644 index 000000000000..d3ccce82751b --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Resource.cs @@ -0,0 +1,100 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An azure resource object + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Resource location + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// Resource tags + public Resource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets azure resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets azure resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets azure resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets resource location + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/Response.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Response.cs new file mode 100644 index 000000000000..828d2ec23b0d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/Response.cs @@ -0,0 +1,144 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response to a metrics query. + /// + public partial class Response + { + /// + /// Initializes a new instance of the Response class. + /// + public Response() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Response class. + /// + /// The timespan for which the data was + /// retrieved. Its value consists of two datetimes concatenated, + /// separated by '/'. This may be adjusted in the future and returned + /// back from what was originally requested. + /// the value of the collection. + /// The integer value representing the relative cost + /// of the query. + /// The interval (window size) for which the + /// metric data was returned in. This may be adjusted in the future + /// and returned back from what was originally requested. This is not + /// present if a metadata request was made. + /// The namespace of the metrics being + /// queried + /// The region of the resource being + /// queried for metrics. + public Response(string timespan, IList value, double? cost = default(double?), System.TimeSpan? interval = default(System.TimeSpan?), string namespaceProperty = default(string), string resourceregion = default(string)) + { + Cost = cost; + Timespan = timespan; + Interval = interval; + NamespaceProperty = namespaceProperty; + Resourceregion = resourceregion; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the integer value representing the relative cost of + /// the query. + /// + [JsonProperty(PropertyName = "cost")] + public double? Cost { get; set; } + + /// + /// Gets or sets the timespan for which the data was retrieved. Its + /// value consists of two datetimes concatenated, separated by '/'. + /// This may be adjusted in the future and returned back from what was + /// originally requested. + /// + [JsonProperty(PropertyName = "timespan")] + public string Timespan { get; set; } + + /// + /// Gets or sets the interval (window size) for which the metric data + /// was returned in. This may be adjusted in the future and returned + /// back from what was originally requested. This is not present if a + /// metadata request was made. + /// + [JsonProperty(PropertyName = "interval")] + public System.TimeSpan? Interval { get; set; } + + /// + /// Gets or sets the namespace of the metrics being queried + /// + [JsonProperty(PropertyName = "namespace")] + public string NamespaceProperty { get; set; } + + /// + /// Gets or sets the region of the resource being queried for metrics. + /// + [JsonProperty(PropertyName = "resourceregion")] + public string Resourceregion { get; set; } + + /// + /// Gets or sets the value of the collection. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Timespan == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Timespan"); + } + if (Value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + } + if (Cost != null) + { + if (Cost < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Cost", 0); + } + } + if (Value != null) + { + foreach (var element in Value) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ResultType.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ResultType.cs new file mode 100644 index 000000000000..d0133162a521 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ResultType.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ResultType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ResultType + { + [EnumMember(Value = "Data")] + Data, + [EnumMember(Value = "Metadata")] + Metadata + } + internal static class ResultTypeEnumExtension + { + internal static string ToSerializedValue(this ResultType? value) + { + return value == null ? null : ((ResultType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ResultType value) + { + switch( value ) + { + case ResultType.Data: + return "Data"; + case ResultType.Metadata: + return "Metadata"; + } + return null; + } + + internal static ResultType? ParseResultType(this string value) + { + switch( value ) + { + case "Data": + return ResultType.Data; + case "Metadata": + return ResultType.Metadata; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RetentionPolicy.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RetentionPolicy.cs new file mode 100644 index 000000000000..683b0b6aa07a --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RetentionPolicy.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Specifies the retention policy for the log. + /// + public partial class RetentionPolicy + { + /// + /// Initializes a new instance of the RetentionPolicy class. + /// + public RetentionPolicy() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RetentionPolicy class. + /// + /// a value indicating whether the retention + /// policy is enabled. + /// the number of days for the retention in days. A + /// value of 0 will retain the events indefinitely. + public RetentionPolicy(bool enabled, int days) + { + Enabled = enabled; + Days = days; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a value indicating whether the retention policy is + /// enabled. + /// + [JsonProperty(PropertyName = "enabled")] + public bool Enabled { get; set; } + + /// + /// Gets or sets the number of days for the retention in days. A value + /// of 0 will retain the events indefinitely. + /// + [JsonProperty(PropertyName = "days")] + public int Days { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Days < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Days", 0); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleAction.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleAction.cs new file mode 100644 index 000000000000..477a7bd77c29 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleAction.cs @@ -0,0 +1,38 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The action that is performed when the alert rule becomes active, and + /// when an alert condition is resolved. + /// + [Newtonsoft.Json.JsonObject("RuleAction")] + public partial class RuleAction + { + /// + /// Initializes a new instance of the RuleAction class. + /// + public RuleAction() + { + CustomInit(); + } + + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleCondition.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleCondition.cs new file mode 100644 index 000000000000..4a1d4ec4aa1f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleCondition.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The condition that results in the alert rule being activated. + /// + [Newtonsoft.Json.JsonObject("RuleCondition")] + public partial class RuleCondition + { + /// + /// Initializes a new instance of the RuleCondition class. + /// + public RuleCondition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleCondition class. + /// + /// the resource from which the rule collects + /// its data. For this type dataSource will always be of type + /// RuleMetricDataSource. + public RuleCondition(RuleDataSource dataSource = default(RuleDataSource)) + { + DataSource = dataSource; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource from which the rule collects its data. + /// For this type dataSource will always be of type + /// RuleMetricDataSource. + /// + [JsonProperty(PropertyName = "dataSource")] + public RuleDataSource DataSource { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleDataSource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleDataSource.cs new file mode 100644 index 000000000000..70b74b15f0fb --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleDataSource.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource from which the rule collects its data. + /// + [Newtonsoft.Json.JsonObject("RuleDataSource")] + public partial class RuleDataSource + { + /// + /// Initializes a new instance of the RuleDataSource class. + /// + public RuleDataSource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleDataSource class. + /// + /// the resource identifier of the resource + /// the rule monitors. **NOTE**: this property cannot be updated for an + /// existing rule. + /// the legacy resource identifier of + /// the resource the rule monitors. **NOTE**: this property cannot be + /// updated for an existing rule. + /// the location of the + /// resource. + /// the namespace of the metric. + public RuleDataSource(string resourceUri = default(string), string legacyResourceId = default(string), string resourceLocation = default(string), string metricNamespace = default(string)) + { + ResourceUri = resourceUri; + LegacyResourceId = legacyResourceId; + ResourceLocation = resourceLocation; + MetricNamespace = metricNamespace; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource identifier of the resource the rule + /// monitors. **NOTE**: this property cannot be updated for an existing + /// rule. + /// + [JsonProperty(PropertyName = "resourceUri")] + public string ResourceUri { get; set; } + + /// + /// Gets or sets the legacy resource identifier of the resource the + /// rule monitors. **NOTE**: this property cannot be updated for an + /// existing rule. + /// + [JsonProperty(PropertyName = "legacyResourceId")] + public string LegacyResourceId { get; set; } + + /// + /// Gets or sets the location of the resource. + /// + [JsonProperty(PropertyName = "resourceLocation")] + public string ResourceLocation { get; set; } + + /// + /// Gets or sets the namespace of the metric. + /// + [JsonProperty(PropertyName = "metricNamespace")] + public string MetricNamespace { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleEmailAction.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleEmailAction.cs new file mode 100644 index 000000000000..5c8972fa6dec --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleEmailAction.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies the action to send email when the rule condition is + /// evaluated. The discriminator is always RuleEmailAction in this case. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Management.Insights.Models.RuleEmailAction")] + public partial class RuleEmailAction : RuleAction + { + /// + /// Initializes a new instance of the RuleEmailAction class. + /// + public RuleEmailAction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleEmailAction class. + /// + /// Whether the administrators + /// (service and co-administrators) of the service should be notified + /// when the alert is activated. + /// the list of administrator's custom email + /// addresses to notify of the activation of the alert. + public RuleEmailAction(bool? sendToServiceOwners = default(bool?), IList customEmails = default(IList)) + { + SendToServiceOwners = sendToServiceOwners; + CustomEmails = customEmails; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets whether the administrators (service and + /// co-administrators) of the service should be notified when the alert + /// is activated. + /// + [JsonProperty(PropertyName = "sendToServiceOwners")] + public bool? SendToServiceOwners { get; set; } + + /// + /// Gets or sets the list of administrator's custom email addresses to + /// notify of the activation of the alert. + /// + [JsonProperty(PropertyName = "customEmails")] + public IList CustomEmails { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleManagementEventClaimsDataSource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleManagementEventClaimsDataSource.cs new file mode 100644 index 000000000000..d2acb8d1268c --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleManagementEventClaimsDataSource.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The claims for a rule management event data source. + /// + public partial class RuleManagementEventClaimsDataSource + { + /// + /// Initializes a new instance of the + /// RuleManagementEventClaimsDataSource class. + /// + public RuleManagementEventClaimsDataSource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// RuleManagementEventClaimsDataSource class. + /// + /// the email address. + public RuleManagementEventClaimsDataSource(string emailAddress = default(string)) + { + EmailAddress = emailAddress; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the email address. + /// + [JsonProperty(PropertyName = "emailAddress")] + public string EmailAddress { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleManagementEventDataSource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleManagementEventDataSource.cs new file mode 100644 index 000000000000..8c50bf453300 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleManagementEventDataSource.cs @@ -0,0 +1,136 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A rule management event data source. The discriminator fields is always + /// RuleManagementEventDataSource in this case. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource")] + public partial class RuleManagementEventDataSource : RuleDataSource + { + /// + /// Initializes a new instance of the RuleManagementEventDataSource + /// class. + /// + public RuleManagementEventDataSource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleManagementEventDataSource + /// class. + /// + /// the resource identifier of the resource + /// the rule monitors. **NOTE**: this property cannot be updated for an + /// existing rule. + /// the legacy resource identifier of + /// the resource the rule monitors. **NOTE**: this property cannot be + /// updated for an existing rule. + /// the location of the + /// resource. + /// the namespace of the metric. + /// the event name. + /// the event source. + /// the level. + /// The name of the operation that should + /// be checked for. If no name is provided, any operation will + /// match. + /// the resource group name. + /// the resource provider + /// name. + /// The status of the operation that should be + /// checked for. If no status is provided, any status will + /// match. + /// the substatus. + /// the claims. + public RuleManagementEventDataSource(string resourceUri = default(string), string legacyResourceId = default(string), string resourceLocation = default(string), string metricNamespace = default(string), string eventName = default(string), string eventSource = default(string), string level = default(string), string operationName = default(string), string resourceGroupName = default(string), string resourceProviderName = default(string), string status = default(string), string subStatus = default(string), RuleManagementEventClaimsDataSource claims = default(RuleManagementEventClaimsDataSource)) + : base(resourceUri, legacyResourceId, resourceLocation, metricNamespace) + { + EventName = eventName; + EventSource = eventSource; + Level = level; + OperationName = operationName; + ResourceGroupName = resourceGroupName; + ResourceProviderName = resourceProviderName; + Status = status; + SubStatus = subStatus; + Claims = claims; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the event name. + /// + [JsonProperty(PropertyName = "eventName")] + public string EventName { get; set; } + + /// + /// Gets or sets the event source. + /// + [JsonProperty(PropertyName = "eventSource")] + public string EventSource { get; set; } + + /// + /// Gets or sets the level. + /// + [JsonProperty(PropertyName = "level")] + public string Level { get; set; } + + /// + /// Gets or sets the name of the operation that should be checked for. + /// If no name is provided, any operation will match. + /// + [JsonProperty(PropertyName = "operationName")] + public string OperationName { get; set; } + + /// + /// Gets or sets the resource group name. + /// + [JsonProperty(PropertyName = "resourceGroupName")] + public string ResourceGroupName { get; set; } + + /// + /// Gets or sets the resource provider name. + /// + [JsonProperty(PropertyName = "resourceProviderName")] + public string ResourceProviderName { get; set; } + + /// + /// Gets or sets the status of the operation that should be checked + /// for. If no status is provided, any status will match. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets the substatus. + /// + [JsonProperty(PropertyName = "subStatus")] + public string SubStatus { get; set; } + + /// + /// Gets or sets the claims. + /// + [JsonProperty(PropertyName = "claims")] + public RuleManagementEventClaimsDataSource Claims { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleMetricDataSource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleMetricDataSource.cs new file mode 100644 index 000000000000..7b650acc4bff --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleMetricDataSource.cs @@ -0,0 +1,65 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A rule metric data source. The discriminator value is always + /// RuleMetricDataSource in this case. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource")] + public partial class RuleMetricDataSource : RuleDataSource + { + /// + /// Initializes a new instance of the RuleMetricDataSource class. + /// + public RuleMetricDataSource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleMetricDataSource class. + /// + /// the resource identifier of the resource + /// the rule monitors. **NOTE**: this property cannot be updated for an + /// existing rule. + /// the legacy resource identifier of + /// the resource the rule monitors. **NOTE**: this property cannot be + /// updated for an existing rule. + /// the location of the + /// resource. + /// the namespace of the metric. + /// the name of the metric that defines what + /// the rule monitors. + public RuleMetricDataSource(string resourceUri = default(string), string legacyResourceId = default(string), string resourceLocation = default(string), string metricNamespace = default(string), string metricName = default(string)) + : base(resourceUri, legacyResourceId, resourceLocation, metricNamespace) + { + MetricName = metricName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the metric that defines what the rule + /// monitors. + /// + [JsonProperty(PropertyName = "metricName")] + public string MetricName { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleWebhookAction.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleWebhookAction.cs new file mode 100644 index 000000000000..b70d12e5444b --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/RuleWebhookAction.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies the action to post to service when the rule condition is + /// evaluated. The discriminator is always RuleWebhookAction in this case. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Management.Insights.Models.RuleWebhookAction")] + public partial class RuleWebhookAction : RuleAction + { + /// + /// Initializes a new instance of the RuleWebhookAction class. + /// + public RuleWebhookAction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RuleWebhookAction class. + /// + /// the service uri to Post the notification + /// when the alert activates or resolves. + /// the dictionary of custom properties to + /// include with the post operation. These data are appended to the + /// webhook payload. + public RuleWebhookAction(string serviceUri = default(string), IDictionary properties = default(IDictionary)) + { + ServiceUri = serviceUri; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the service uri to Post the notification when the + /// alert activates or resolves. + /// + [JsonProperty(PropertyName = "serviceUri")] + public string ServiceUri { get; set; } + + /// + /// Gets or sets the dictionary of custom properties to include with + /// the post operation. These data are appended to the webhook payload. + /// + [JsonProperty(PropertyName = "properties")] + public IDictionary Properties { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleAction.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleAction.cs new file mode 100644 index 000000000000..9f23316376c8 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleAction.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The parameters for the scaling action. + /// + public partial class ScaleAction + { + /// + /// Initializes a new instance of the ScaleAction class. + /// + public ScaleAction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScaleAction class. + /// + /// the scale direction. Whether the scaling + /// action increases or decreases the number of instances. Possible + /// values include: 'None', 'Increase', 'Decrease' + /// the type of action that should occur when the + /// scale rule fires. Possible values include: 'ChangeCount', + /// 'PercentChangeCount', 'ExactCount', + /// 'ServiceAllowedNextValue' + /// the amount of time to wait since the last + /// scaling action before this action occurs. It must be between 1 week + /// and 1 minute in ISO 8601 format. + /// the number of instances that are involved in + /// the scaling action. This value must be 1 or greater. The default + /// value is 1. + public ScaleAction(ScaleDirection direction, ScaleType type, System.TimeSpan cooldown, string value = default(string)) + { + Direction = direction; + Type = type; + Value = value; + Cooldown = cooldown; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the scale direction. Whether the scaling action + /// increases or decreases the number of instances. Possible values + /// include: 'None', 'Increase', 'Decrease' + /// + [JsonProperty(PropertyName = "direction")] + public ScaleDirection Direction { get; set; } + + /// + /// Gets or sets the type of action that should occur when the scale + /// rule fires. Possible values include: 'ChangeCount', + /// 'PercentChangeCount', 'ExactCount', 'ServiceAllowedNextValue' + /// + [JsonProperty(PropertyName = "type")] + public ScaleType Type { get; set; } + + /// + /// Gets or sets the number of instances that are involved in the + /// scaling action. This value must be 1 or greater. The default value + /// is 1. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Gets or sets the amount of time to wait since the last scaling + /// action before this action occurs. It must be between 1 week and 1 + /// minute in ISO 8601 format. + /// + [JsonProperty(PropertyName = "cooldown")] + public System.TimeSpan Cooldown { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleCapacity.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleCapacity.cs new file mode 100644 index 000000000000..755f92253b1f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleCapacity.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The number of instances that can be used during this profile. + /// + public partial class ScaleCapacity + { + /// + /// Initializes a new instance of the ScaleCapacity class. + /// + public ScaleCapacity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScaleCapacity class. + /// + /// the minimum number of instances for the + /// resource. + /// the maximum number of instances for the + /// resource. The actual maximum number of instances is limited by the + /// cores that are available in the subscription. + /// the number of instances that will be + /// set if metrics are not available for evaluation. The default is + /// only used if the current instance count is lower than the + /// default. + public ScaleCapacity(string minimum, string maximum, string defaultProperty) + { + Minimum = minimum; + Maximum = maximum; + DefaultProperty = defaultProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the minimum number of instances for the resource. + /// + [JsonProperty(PropertyName = "minimum")] + public string Minimum { get; set; } + + /// + /// Gets or sets the maximum number of instances for the resource. The + /// actual maximum number of instances is limited by the cores that are + /// available in the subscription. + /// + [JsonProperty(PropertyName = "maximum")] + public string Maximum { get; set; } + + /// + /// Gets or sets the number of instances that will be set if metrics + /// are not available for evaluation. The default is only used if the + /// current instance count is lower than the default. + /// + [JsonProperty(PropertyName = "default")] + public string DefaultProperty { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Minimum == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Minimum"); + } + if (Maximum == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Maximum"); + } + if (DefaultProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DefaultProperty"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleDirection.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleDirection.cs new file mode 100644 index 000000000000..858c37739fdb --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleDirection.cs @@ -0,0 +1,66 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ScaleDirection. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ScaleDirection + { + [EnumMember(Value = "None")] + None, + [EnumMember(Value = "Increase")] + Increase, + [EnumMember(Value = "Decrease")] + Decrease + } + internal static class ScaleDirectionEnumExtension + { + internal static string ToSerializedValue(this ScaleDirection? value) + { + return value == null ? null : ((ScaleDirection)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ScaleDirection value) + { + switch( value ) + { + case ScaleDirection.None: + return "None"; + case ScaleDirection.Increase: + return "Increase"; + case ScaleDirection.Decrease: + return "Decrease"; + } + return null; + } + + internal static ScaleDirection? ParseScaleDirection(this string value) + { + switch( value ) + { + case "None": + return ScaleDirection.None; + case "Increase": + return ScaleDirection.Increase; + case "Decrease": + return ScaleDirection.Decrease; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRule.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRule.cs new file mode 100644 index 000000000000..2f061a1523d5 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRule.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A rule that provide the triggers and parameters for the scaling action. + /// + public partial class ScaleRule + { + /// + /// Initializes a new instance of the ScaleRule class. + /// + public ScaleRule() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScaleRule class. + /// + /// the trigger that results in a scaling + /// action. + /// the parameters for the scaling + /// action. + public ScaleRule(MetricTrigger metricTrigger, ScaleAction scaleAction) + { + MetricTrigger = metricTrigger; + ScaleAction = scaleAction; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the trigger that results in a scaling action. + /// + [JsonProperty(PropertyName = "metricTrigger")] + public MetricTrigger MetricTrigger { get; set; } + + /// + /// Gets or sets the parameters for the scaling action. + /// + [JsonProperty(PropertyName = "scaleAction")] + public ScaleAction ScaleAction { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (MetricTrigger == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MetricTrigger"); + } + if (ScaleAction == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ScaleAction"); + } + if (MetricTrigger != null) + { + MetricTrigger.Validate(); + } + if (ScaleAction != null) + { + ScaleAction.Validate(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRuleMetricDimension.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRuleMetricDimension.cs new file mode 100644 index 000000000000..9cb036d6fed2 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRuleMetricDimension.cs @@ -0,0 +1,99 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies an auto scale rule metric dimension. + /// + public partial class ScaleRuleMetricDimension + { + /// + /// Initializes a new instance of the ScaleRuleMetricDimension class. + /// + public ScaleRuleMetricDimension() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScaleRuleMetricDimension class. + /// + /// Name of the dimension. + /// the dimension operator. Only + /// 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any + /// of the values. 'NotEquals' being not equal to all of the values. + /// Possible values include: 'Equals', 'NotEquals' + /// list of dimension values. For example: + /// ["App1","App2"]. + public ScaleRuleMetricDimension(string dimensionName, string operatorProperty, IList values) + { + DimensionName = dimensionName; + OperatorProperty = operatorProperty; + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the dimension. + /// + [JsonProperty(PropertyName = "DimensionName")] + public string DimensionName { get; set; } + + /// + /// Gets or sets the dimension operator. Only 'Equals' and 'NotEquals' + /// are supported. 'Equals' being equal to any of the values. + /// 'NotEquals' being not equal to all of the values. Possible values + /// include: 'Equals', 'NotEquals' + /// + [JsonProperty(PropertyName = "Operator")] + public string OperatorProperty { get; set; } + + /// + /// Gets or sets list of dimension values. For example: + /// ["App1","App2"]. + /// + [JsonProperty(PropertyName = "Values")] + public IList Values { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (DimensionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "DimensionName"); + } + if (OperatorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperatorProperty"); + } + if (Values == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Values"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRuleMetricDimensionOperationType.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRuleMetricDimensionOperationType.cs new file mode 100644 index 000000000000..3ff0455f3c4e --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleRuleMetricDimensionOperationType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + + /// + /// Defines values for ScaleRuleMetricDimensionOperationType. + /// + public static class ScaleRuleMetricDimensionOperationType + { + public const string Equals = "Equals"; + public const string NotEquals = "NotEquals"; + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleType.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleType.cs new file mode 100644 index 000000000000..de3dbf23de2f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScaleType.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ScaleType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ScaleType + { + [EnumMember(Value = "ChangeCount")] + ChangeCount, + [EnumMember(Value = "PercentChangeCount")] + PercentChangeCount, + [EnumMember(Value = "ExactCount")] + ExactCount, + [EnumMember(Value = "ServiceAllowedNextValue")] + ServiceAllowedNextValue + } + internal static class ScaleTypeEnumExtension + { + internal static string ToSerializedValue(this ScaleType? value) + { + return value == null ? null : ((ScaleType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ScaleType value) + { + switch( value ) + { + case ScaleType.ChangeCount: + return "ChangeCount"; + case ScaleType.PercentChangeCount: + return "PercentChangeCount"; + case ScaleType.ExactCount: + return "ExactCount"; + case ScaleType.ServiceAllowedNextValue: + return "ServiceAllowedNextValue"; + } + return null; + } + + internal static ScaleType? ParseScaleType(this string value) + { + switch( value ) + { + case "ChangeCount": + return ScaleType.ChangeCount; + case "PercentChangeCount": + return ScaleType.PercentChangeCount; + case "ExactCount": + return ScaleType.ExactCount; + case "ServiceAllowedNextValue": + return ScaleType.ServiceAllowedNextValue; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScopedResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScopedResource.cs new file mode 100644 index 000000000000..bbfe8c1a2fad --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ScopedResource.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A private link scoped resource + /// + [Rest.Serialization.JsonTransformation] + public partial class ScopedResource : ProxyResource + { + /// + /// Initializes a new instance of the ScopedResource class. + /// + public ScopedResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ScopedResource class. + /// + /// Azure resource Id + /// Azure resource name + /// Azure resource type + /// The resource id of the scoped Azure + /// monitor resource. + /// State of the private endpoint + /// connection. + public ScopedResource(string id = default(string), string name = default(string), string type = default(string), string linkedResourceId = default(string), string provisioningState = default(string)) + : base(id, name, type) + { + LinkedResourceId = linkedResourceId; + ProvisioningState = provisioningState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource id of the scoped Azure monitor resource. + /// + [JsonProperty(PropertyName = "properties.linkedResourceId")] + public string LinkedResourceId { get; set; } + + /// + /// Gets state of the private endpoint connection. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/SenderAuthorization.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/SenderAuthorization.cs new file mode 100644 index 000000000000..b039c91346dd --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/SenderAuthorization.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// the authorization used by the user who has performed the operation that + /// led to this event. This captures the RBAC properties of the event. + /// These usually include the 'action', 'role' and the 'scope' + /// + public partial class SenderAuthorization + { + /// + /// Initializes a new instance of the SenderAuthorization class. + /// + public SenderAuthorization() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SenderAuthorization class. + /// + /// the permissible actions. For instance: + /// microsoft.support/supporttickets/write + /// the role of the user. For instance: Subscription + /// Admin + /// the scope. + public SenderAuthorization(string action = default(string), string role = default(string), string scope = default(string)) + { + Action = action; + Role = role; + Scope = scope; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the permissible actions. For instance: + /// microsoft.support/supporttickets/write + /// + [JsonProperty(PropertyName = "action")] + public string Action { get; set; } + + /// + /// Gets or sets the role of the user. For instance: Subscription Admin + /// + [JsonProperty(PropertyName = "role")] + public string Role { get; set; } + + /// + /// Gets or sets the scope. + /// + [JsonProperty(PropertyName = "scope")] + public string Scope { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/SingleBaseline.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/SingleBaseline.cs new file mode 100644 index 000000000000..8959f4d061eb --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/SingleBaseline.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The baseline values for a single sensitivity value. + /// + public partial class SingleBaseline + { + /// + /// Initializes a new instance of the SingleBaseline class. + /// + public SingleBaseline() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SingleBaseline class. + /// + /// the sensitivity of the baseline. Possible + /// values include: 'Low', 'Medium', 'High' + /// The low thresholds of the + /// baseline. + /// The high thresholds of the + /// baseline. + public SingleBaseline(string sensitivity, IList lowThresholds, IList highThresholds) + { + Sensitivity = sensitivity; + LowThresholds = lowThresholds; + HighThresholds = highThresholds; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the sensitivity of the baseline. Possible values + /// include: 'Low', 'Medium', 'High' + /// + [JsonProperty(PropertyName = "sensitivity")] + public string Sensitivity { get; set; } + + /// + /// Gets or sets the low thresholds of the baseline. + /// + [JsonProperty(PropertyName = "lowThresholds")] + public IList LowThresholds { get; set; } + + /// + /// Gets or sets the high thresholds of the baseline. + /// + [JsonProperty(PropertyName = "highThresholds")] + public IList HighThresholds { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Sensitivity == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Sensitivity"); + } + if (LowThresholds == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "LowThresholds"); + } + if (HighThresholds == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "HighThresholds"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/SingleMetricBaseline.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/SingleMetricBaseline.cs new file mode 100644 index 000000000000..d7d36f282e52 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/SingleMetricBaseline.cs @@ -0,0 +1,160 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The baseline results of a single metric. + /// + [Rest.Serialization.JsonTransformation] + public partial class SingleMetricBaseline + { + /// + /// Initializes a new instance of the SingleMetricBaseline class. + /// + public SingleMetricBaseline() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SingleMetricBaseline class. + /// + /// The metric baseline Id. + /// The resource type of the metric baseline + /// resource. + /// The name of the metric for which the baselines + /// were retrieved. + /// The timespan for which the data was + /// retrieved. Its value consists of two datetimes concatenated, + /// separated by '/'. This may be adjusted in the future and returned + /// back from what was originally requested. + /// The interval (window size) for which the + /// metric data was returned in. This may be adjusted in the future + /// and returned back from what was originally requested. This is not + /// present if a metadata request was made. + /// The baseline for each time series that was + /// queried. + /// The namespace of the metrics been + /// queried. + public SingleMetricBaseline(string id, string type, string name, string timespan, System.TimeSpan interval, IList baselines, string namespaceProperty = default(string)) + { + Id = id; + Type = type; + Name = name; + Timespan = timespan; + Interval = interval; + NamespaceProperty = namespaceProperty; + Baselines = baselines; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the metric baseline Id. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the resource type of the metric baseline resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the name of the metric for which the baselines were + /// retrieved. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the timespan for which the data was retrieved. Its + /// value consists of two datetimes concatenated, separated by '/'. + /// This may be adjusted in the future and returned back from what was + /// originally requested. + /// + [JsonProperty(PropertyName = "properties.timespan")] + public string Timespan { get; set; } + + /// + /// Gets or sets the interval (window size) for which the metric data + /// was returned in. This may be adjusted in the future and returned + /// back from what was originally requested. This is not present if a + /// metadata request was made. + /// + [JsonProperty(PropertyName = "properties.interval")] + public System.TimeSpan Interval { get; set; } + + /// + /// Gets or sets the namespace of the metrics been queried. + /// + [JsonProperty(PropertyName = "properties.namespace")] + public string NamespaceProperty { get; set; } + + /// + /// Gets or sets the baseline for each time series that was queried. + /// + [JsonProperty(PropertyName = "properties.baselines")] + public IList Baselines { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Timespan == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Timespan"); + } + if (Baselines == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Baselines"); + } + if (Baselines != null) + { + foreach (var element in Baselines) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/TagsResource.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TagsResource.cs new file mode 100644 index 000000000000..3dc9207c30c3 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TagsResource.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A container holding only the Tags for a resource, allowing the user to + /// update the tags on a PrivateLinkScope instance. + /// + public partial class TagsResource + { + /// + /// Initializes a new instance of the TagsResource class. + /// + public TagsResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TagsResource class. + /// + /// Resource tags + public TagsResource(IDictionary tags = default(IDictionary)) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/ThresholdRuleCondition.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ThresholdRuleCondition.cs new file mode 100644 index 000000000000..e376a972718d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/ThresholdRuleCondition.cs @@ -0,0 +1,106 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A rule condition based on a metric crossing a threshold. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition")] + public partial class ThresholdRuleCondition : RuleCondition + { + /// + /// Initializes a new instance of the ThresholdRuleCondition class. + /// + public ThresholdRuleCondition() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ThresholdRuleCondition class. + /// + /// the operator used to compare the + /// data and the threshold. Possible values include: 'GreaterThan', + /// 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + /// the threshold value that activates the + /// alert. + /// the resource from which the rule collects + /// its data. For this type dataSource will always be of type + /// RuleMetricDataSource. + /// the period of time (in ISO 8601 duration + /// format) that is used to monitor alert activity based on the + /// threshold. If specified then it must be between 5 minutes and 1 + /// day. + /// the time aggregation operator. How + /// the data that are collected should be combined over time. The + /// default value is the PrimaryAggregationType of the Metric. Possible + /// values include: 'Average', 'Minimum', 'Maximum', 'Total', + /// 'Last' + public ThresholdRuleCondition(ConditionOperator operatorProperty, double threshold, RuleDataSource dataSource = default(RuleDataSource), System.TimeSpan? windowSize = default(System.TimeSpan?), TimeAggregationOperator? timeAggregation = default(TimeAggregationOperator?)) + : base(dataSource) + { + OperatorProperty = operatorProperty; + Threshold = threshold; + WindowSize = windowSize; + TimeAggregation = timeAggregation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the operator used to compare the data and the + /// threshold. Possible values include: 'GreaterThan', + /// 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + /// + [JsonProperty(PropertyName = "operator")] + public ConditionOperator OperatorProperty { get; set; } + + /// + /// Gets or sets the threshold value that activates the alert. + /// + [JsonProperty(PropertyName = "threshold")] + public double Threshold { get; set; } + + /// + /// Gets or sets the period of time (in ISO 8601 duration format) that + /// is used to monitor alert activity based on the threshold. If + /// specified then it must be between 5 minutes and 1 day. + /// + [JsonProperty(PropertyName = "windowSize")] + public System.TimeSpan? WindowSize { get; set; } + + /// + /// Gets or sets the time aggregation operator. How the data that are + /// collected should be combined over time. The default value is the + /// PrimaryAggregationType of the Metric. Possible values include: + /// 'Average', 'Minimum', 'Maximum', 'Total', 'Last' + /// + [JsonProperty(PropertyName = "timeAggregation")] + public TimeAggregationOperator? TimeAggregation { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeAggregationOperator.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeAggregationOperator.cs new file mode 100644 index 000000000000..863bbac3ce8a --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeAggregationOperator.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for TimeAggregationOperator. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum TimeAggregationOperator + { + [EnumMember(Value = "Average")] + Average, + [EnumMember(Value = "Minimum")] + Minimum, + [EnumMember(Value = "Maximum")] + Maximum, + [EnumMember(Value = "Total")] + Total, + [EnumMember(Value = "Last")] + Last + } + internal static class TimeAggregationOperatorEnumExtension + { + internal static string ToSerializedValue(this TimeAggregationOperator? value) + { + return value == null ? null : ((TimeAggregationOperator)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this TimeAggregationOperator value) + { + switch( value ) + { + case TimeAggregationOperator.Average: + return "Average"; + case TimeAggregationOperator.Minimum: + return "Minimum"; + case TimeAggregationOperator.Maximum: + return "Maximum"; + case TimeAggregationOperator.Total: + return "Total"; + case TimeAggregationOperator.Last: + return "Last"; + } + return null; + } + + internal static TimeAggregationOperator? ParseTimeAggregationOperator(this string value) + { + switch( value ) + { + case "Average": + return TimeAggregationOperator.Average; + case "Minimum": + return TimeAggregationOperator.Minimum; + case "Maximum": + return TimeAggregationOperator.Maximum; + case "Total": + return TimeAggregationOperator.Total; + case "Last": + return TimeAggregationOperator.Last; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeAggregationType.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeAggregationType.cs new file mode 100644 index 000000000000..771c356ab52e --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeAggregationType.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for TimeAggregationType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum TimeAggregationType + { + [EnumMember(Value = "Average")] + Average, + [EnumMember(Value = "Minimum")] + Minimum, + [EnumMember(Value = "Maximum")] + Maximum, + [EnumMember(Value = "Total")] + Total, + [EnumMember(Value = "Count")] + Count, + [EnumMember(Value = "Last")] + Last + } + internal static class TimeAggregationTypeEnumExtension + { + internal static string ToSerializedValue(this TimeAggregationType? value) + { + return value == null ? null : ((TimeAggregationType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this TimeAggregationType value) + { + switch( value ) + { + case TimeAggregationType.Average: + return "Average"; + case TimeAggregationType.Minimum: + return "Minimum"; + case TimeAggregationType.Maximum: + return "Maximum"; + case TimeAggregationType.Total: + return "Total"; + case TimeAggregationType.Count: + return "Count"; + case TimeAggregationType.Last: + return "Last"; + } + return null; + } + + internal static TimeAggregationType? ParseTimeAggregationType(this string value) + { + switch( value ) + { + case "Average": + return TimeAggregationType.Average; + case "Minimum": + return TimeAggregationType.Minimum; + case "Maximum": + return TimeAggregationType.Maximum; + case "Total": + return TimeAggregationType.Total; + case "Count": + return TimeAggregationType.Count; + case "Last": + return TimeAggregationType.Last; + } + return null; + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeSeriesBaseline.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeSeriesBaseline.cs new file mode 100644 index 000000000000..931c37ed3405 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeSeriesBaseline.cs @@ -0,0 +1,141 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The baseline values for a single time series. + /// + public partial class TimeSeriesBaseline + { + /// + /// Initializes a new instance of the TimeSeriesBaseline class. + /// + public TimeSeriesBaseline() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TimeSeriesBaseline class. + /// + /// The aggregation type of the + /// metric. + /// The list of timestamps of the + /// baselines. + /// The baseline values for each + /// sensitivity. + /// The dimensions of this time + /// series. + /// The baseline metadata values. + public TimeSeriesBaseline(string aggregation, IList timestamps, IList data, IList dimensions = default(IList), IList metadataValues = default(IList)) + { + Aggregation = aggregation; + Dimensions = dimensions; + Timestamps = timestamps; + Data = data; + MetadataValues = metadataValues; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the aggregation type of the metric. + /// + [JsonProperty(PropertyName = "aggregation")] + public string Aggregation { get; set; } + + /// + /// Gets or sets the dimensions of this time series. + /// + [JsonProperty(PropertyName = "dimensions")] + public IList Dimensions { get; set; } + + /// + /// Gets or sets the list of timestamps of the baselines. + /// + [JsonProperty(PropertyName = "timestamps")] + public IList Timestamps { get; set; } + + /// + /// Gets or sets the baseline values for each sensitivity. + /// + [JsonProperty(PropertyName = "data")] + public IList Data { get; set; } + + /// + /// Gets or sets the baseline metadata values. + /// + [JsonProperty(PropertyName = "metadataValues")] + public IList MetadataValues { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Aggregation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Aggregation"); + } + if (Timestamps == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Timestamps"); + } + if (Data == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Data"); + } + if (Dimensions != null) + { + foreach (var element in Dimensions) + { + if (element != null) + { + element.Validate(); + } + } + } + if (Data != null) + { + foreach (var element1 in Data) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (MetadataValues != null) + { + foreach (var element2 in MetadataValues) + { + if (element2 != null) + { + element2.Validate(); + } + } + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeSeriesElement.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeSeriesElement.cs new file mode 100644 index 000000000000..6d30fba03f4f --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeSeriesElement.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A time series result type. The discriminator value is always TimeSeries + /// in this case. + /// + public partial class TimeSeriesElement + { + /// + /// Initializes a new instance of the TimeSeriesElement class. + /// + public TimeSeriesElement() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TimeSeriesElement class. + /// + /// the metadata values returned if + /// $filter was specified in the call. + /// An array of data points representing the metric + /// values. This is only returned if a result type of data is + /// specified. + public TimeSeriesElement(IList metadatavalues = default(IList), IList data = default(IList)) + { + Metadatavalues = metadatavalues; + Data = data; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the metadata values returned if $filter was specified + /// in the call. + /// + [JsonProperty(PropertyName = "metadatavalues")] + public IList Metadatavalues { get; set; } + + /// + /// Gets or sets an array of data points representing the metric + /// values. This is only returned if a result type of data is + /// specified. + /// + [JsonProperty(PropertyName = "data")] + public IList Data { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeWindow.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeWindow.cs new file mode 100644 index 000000000000..6eba68156e24 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/TimeWindow.cs @@ -0,0 +1,162 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A specific date-time for the profile. + /// + public partial class TimeWindow + { + /// + /// Initializes a new instance of the TimeWindow class. + /// + public TimeWindow() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TimeWindow class. + /// + /// the start time for the profile in ISO 8601 + /// format. + /// the end time for the profile in ISO 8601 + /// format. + /// the timezone of the start and end times for + /// the profile. Some examples of valid time zones are: Dateline + /// Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard + /// Time, Pacific Standard Time (Mexico), Pacific Standard Time, US + /// Mountain Standard Time, Mountain Standard Time (Mexico), Mountain + /// Standard Time, Central America Standard Time, Central Standard + /// Time, Central Standard Time (Mexico), Canada Central Standard Time, + /// SA Pacific Standard Time, Eastern Standard Time, US Eastern + /// Standard Time, Venezuela Standard Time, Paraguay Standard Time, + /// Atlantic Standard Time, Central Brazilian Standard Time, SA Western + /// Standard Time, Pacific SA Standard Time, Newfoundland Standard + /// Time, E. South America Standard Time, Argentina Standard Time, SA + /// Eastern Standard Time, Greenland Standard Time, Montevideo Standard + /// Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, + /// Azores Standard Time, Cape Verde Standard Time, Morocco Standard + /// Time, UTC, GMT Standard Time, Greenwich Standard Time, W. Europe + /// Standard Time, Central Europe Standard Time, Romance Standard Time, + /// Central European Standard Time, W. Central Africa Standard Time, + /// Namibia Standard Time, Jordan Standard Time, GTB Standard Time, + /// Middle East Standard Time, Egypt Standard Time, Syria Standard + /// Time, E. Europe Standard Time, South Africa Standard Time, FLE + /// Standard Time, Turkey Standard Time, Israel Standard Time, + /// Kaliningrad Standard Time, Libya Standard Time, Arabic Standard + /// Time, Arab Standard Time, Belarus Standard Time, Russian Standard + /// Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard + /// Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + /// Standard Time, Georgian Standard Time, Caucasus Standard Time, + /// Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg + /// Standard Time, Pakistan Standard Time, India Standard Time, Sri + /// Lanka Standard Time, Nepal Standard Time, Central Asia Standard + /// Time, Bangladesh Standard Time, N. Central Asia Standard Time, + /// Myanmar Standard Time, SE Asia Standard Time, North Asia Standard + /// Time, China Standard Time, North Asia East Standard Time, Singapore + /// Standard Time, W. Australia Standard Time, Taipei Standard Time, + /// Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard + /// Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS + /// Central Standard Time, E. Australia Standard Time, AUS Eastern + /// Standard Time, West Pacific Standard Time, Tasmania Standard Time, + /// Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone + /// 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand + /// Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, + /// Tonga Standard Time, Samoa Standard Time, Line Islands Standard + /// Time + public TimeWindow(System.DateTime start, System.DateTime end, string timeZone = default(string)) + { + TimeZone = timeZone; + Start = start; + End = end; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the timezone of the start and end times for the + /// profile. Some examples of valid time zones are: Dateline Standard + /// Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + /// Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain + /// Standard Time, Mountain Standard Time (Mexico), Mountain Standard + /// Time, Central America Standard Time, Central Standard Time, Central + /// Standard Time (Mexico), Canada Central Standard Time, SA Pacific + /// Standard Time, Eastern Standard Time, US Eastern Standard Time, + /// Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard + /// Time, Central Brazilian Standard Time, SA Western Standard Time, + /// Pacific SA Standard Time, Newfoundland Standard Time, E. South + /// America Standard Time, Argentina Standard Time, SA Eastern Standard + /// Time, Greenland Standard Time, Montevideo Standard Time, Bahia + /// Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard + /// Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT + /// Standard Time, Greenwich Standard Time, W. Europe Standard Time, + /// Central Europe Standard Time, Romance Standard Time, Central + /// European Standard Time, W. Central Africa Standard Time, Namibia + /// Standard Time, Jordan Standard Time, GTB Standard Time, Middle East + /// Standard Time, Egypt Standard Time, Syria Standard Time, E. Europe + /// Standard Time, South Africa Standard Time, FLE Standard Time, + /// Turkey Standard Time, Israel Standard Time, Kaliningrad Standard + /// Time, Libya Standard Time, Arabic Standard Time, Arab Standard + /// Time, Belarus Standard Time, Russian Standard Time, E. Africa + /// Standard Time, Iran Standard Time, Arabian Standard Time, + /// Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard + /// Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan + /// Standard Time, West Asia Standard Time, Ekaterinburg Standard Time, + /// Pakistan Standard Time, India Standard Time, Sri Lanka Standard + /// Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh + /// Standard Time, N. Central Asia Standard Time, Myanmar Standard + /// Time, SE Asia Standard Time, North Asia Standard Time, China + /// Standard Time, North Asia East Standard Time, Singapore Standard + /// Time, W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar + /// Standard Time, Tokyo Standard Time, Korea Standard Time, Yakutsk + /// Standard Time, Cen. Australia Standard Time, AUS Central Standard + /// Time, E. Australia Standard Time, AUS Eastern Standard Time, West + /// Pacific Standard Time, Tasmania Standard Time, Magadan Standard + /// Time, Vladivostok Standard Time, Russia Time Zone 10, Central + /// Pacific Standard Time, Russia Time Zone 11, New Zealand Standard + /// Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga + /// Standard Time, Samoa Standard Time, Line Islands Standard Time + /// + [JsonProperty(PropertyName = "timeZone")] + public string TimeZone { get; set; } + + /// + /// Gets or sets the start time for the profile in ISO 8601 format. + /// + [JsonProperty(PropertyName = "start")] + public System.DateTime Start { get; set; } + + /// + /// Gets or sets the end time for the profile in ISO 8601 format. + /// + [JsonProperty(PropertyName = "end")] + public System.DateTime End { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/WebhookNotification.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/WebhookNotification.cs new file mode 100644 index 000000000000..fb61f5519717 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/WebhookNotification.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Webhook notification of an autoscale event. + /// + public partial class WebhookNotification + { + /// + /// Initializes a new instance of the WebhookNotification class. + /// + public WebhookNotification() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WebhookNotification class. + /// + /// the service address to receive the + /// notification. + /// a property bag of settings. This value can + /// be empty. + public WebhookNotification(string serviceUri = default(string), IDictionary properties = default(IDictionary)) + { + ServiceUri = serviceUri; + Properties = properties; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the service address to receive the notification. + /// + [JsonProperty(PropertyName = "serviceUri")] + public string ServiceUri { get; set; } + + /// + /// Gets or sets a property bag of settings. This value can be empty. + /// + [JsonProperty(PropertyName = "properties")] + public IDictionary Properties { get; set; } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/Models/WebtestLocationAvailabilityCriteria.cs b/src/Monitor/Monitor.Management.Sdk/Generated/Models/WebtestLocationAvailabilityCriteria.cs new file mode 100644 index 000000000000..9ade80267628 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/Models/WebtestLocationAvailabilityCriteria.cs @@ -0,0 +1,96 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Specifies the metric alert rule criteria for a web test resource. + /// + [Newtonsoft.Json.JsonObject("Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria")] + public partial class WebtestLocationAvailabilityCriteria : MetricAlertCriteria + { + /// + /// Initializes a new instance of the + /// WebtestLocationAvailabilityCriteria class. + /// + public WebtestLocationAvailabilityCriteria() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// WebtestLocationAvailabilityCriteria class. + /// + /// The Application Insights web test + /// Id. + /// The Application Insights resource + /// Id. + /// The number of failed + /// locations. + /// Unmatched properties from the + /// message are deserialized this collection + public WebtestLocationAvailabilityCriteria(string webTestId, string componentId, double failedLocationCount, IDictionary additionalProperties = default(IDictionary)) + : base(additionalProperties) + { + WebTestId = webTestId; + ComponentId = componentId; + FailedLocationCount = failedLocationCount; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Application Insights web test Id. + /// + [JsonProperty(PropertyName = "webTestId")] + public string WebTestId { get; set; } + + /// + /// Gets or sets the Application Insights resource Id. + /// + [JsonProperty(PropertyName = "componentId")] + public string ComponentId { get; set; } + + /// + /// Gets or sets the number of failed locations. + /// + [JsonProperty(PropertyName = "failedLocationCount")] + public double FailedLocationCount { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (WebTestId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "WebTestId"); + } + if (ComponentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ComponentId"); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/MonitorManagementClient.cs b/src/Monitor/Monitor.Management.Sdk/Generated/MonitorManagementClient.cs new file mode 100644 index 000000000000..05a642c1468c --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/MonitorManagementClient.cs @@ -0,0 +1,460 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + + /// + /// Monitor Management Client + /// + public partial class MonitorManagementClient : ServiceClient, IMonitorManagementClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// The ID of the target subscription. + /// + public string SubscriptionId { get; set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IAutoscaleSettingsOperations. + /// + public virtual IAutoscaleSettingsOperations AutoscaleSettings { get; private set; } + + /// + /// Gets the IAlertRulesOperations. + /// + public virtual IAlertRulesOperations AlertRules { get; private set; } + + /// + /// Gets the ILogProfilesOperations. + /// + public virtual ILogProfilesOperations LogProfiles { get; private set; } + + /// + /// Gets the IDiagnosticSettingsOperations. + /// + public virtual IDiagnosticSettingsOperations DiagnosticSettings { get; private set; } + + /// + /// Gets the IActivityLogsOperations. + /// + public virtual IActivityLogsOperations ActivityLogs { get; private set; } + + /// + /// Gets the IEventCategoriesOperations. + /// + public virtual IEventCategoriesOperations EventCategories { get; private set; } + + /// + /// Gets the IMetricDefinitionsOperations. + /// + public virtual IMetricDefinitionsOperations MetricDefinitions { get; private set; } + + /// + /// Gets the IMetricsOperations. + /// + public virtual IMetricsOperations Metrics { get; private set; } + + /// + /// Gets the IBaselinesOperations. + /// + public virtual IBaselinesOperations Baselines { get; private set; } + + /// + /// Gets the IMetricAlertsOperations. + /// + public virtual IMetricAlertsOperations MetricAlerts { get; private set; } + + /// + /// Gets the IMetricAlertsStatusOperations. + /// + public virtual IMetricAlertsStatusOperations MetricAlertsStatus { get; private set; } + + /// + /// Gets the IMetricNamespacesOperations. + /// + public virtual IMetricNamespacesOperations MetricNamespaces { get; private set; } + + /// + /// Gets the IPrivateLinkScopesOperations. + /// + public virtual IPrivateLinkScopesOperations PrivateLinkScopes { get; private set; } + + /// + /// Gets the IPrivateLinkScopeOperationStatusOperations. + /// + public virtual IPrivateLinkScopeOperationStatusOperations PrivateLinkScopeOperationStatus { get; private set; } + + /// + /// Gets the IPrivateLinkResourcesOperations. + /// + public virtual IPrivateLinkResourcesOperations PrivateLinkResources { get; private set; } + + /// + /// Gets the IPrivateEndpointConnectionsOperations. + /// + public virtual IPrivateEndpointConnectionsOperations PrivateEndpointConnections { get; private set; } + + /// + /// Gets the IPrivateLinkScopedResourcesOperations. + /// + public virtual IPrivateLinkScopedResourcesOperations PrivateLinkScopedResources { get; private set; } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling MonitorManagementClient.Dispose(). False: will not dispose provided httpClient + protected MonitorManagementClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected MonitorManagementClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected MonitorManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected MonitorManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected MonitorManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MonitorManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling MonitorManagementClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public MonitorManagementClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MonitorManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MonitorManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the MonitorManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public MonitorManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + AutoscaleSettings = new AutoscaleSettingsOperations(this); + AlertRules = new AlertRulesOperations(this); + LogProfiles = new LogProfilesOperations(this); + DiagnosticSettings = new DiagnosticSettingsOperations(this); + ActivityLogs = new ActivityLogsOperations(this); + EventCategories = new EventCategoriesOperations(this); + MetricDefinitions = new MetricDefinitionsOperations(this); + Metrics = new MetricsOperations(this); + Baselines = new BaselinesOperations(this); + MetricAlerts = new MetricAlertsOperations(this); + MetricAlertsStatus = new MetricAlertsStatusOperations(this); + MetricNamespaces = new MetricNamespacesOperations(this); + PrivateLinkScopes = new PrivateLinkScopesOperations(this); + PrivateLinkScopeOperationStatus = new PrivateLinkScopeOperationStatusOperations(this); + PrivateLinkResources = new PrivateLinkResourcesOperations(this); + PrivateEndpointConnections = new PrivateEndpointConnectionsOperations(this); + PrivateLinkScopedResources = new PrivateLinkScopedResourcesOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("odata.type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("odata.type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("odata.type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("odata.type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("odata.type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("odata.type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("odata.type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("odata.type")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("criterionType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("criterionType")); + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateEndpointConnectionsOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateEndpointConnectionsOperations.cs new file mode 100644 index 000000000000..f23a07af866b --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateEndpointConnectionsOperations.cs @@ -0,0 +1,1150 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateEndpointConnectionsOperations operations. + /// + internal partial class PrivateEndpointConnectionsOperations : IServiceOperations, IPrivateEndpointConnectionsOperations + { + /// + /// Initializes a new instance of the PrivateEndpointConnectionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateEndpointConnectionsOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Gets a private endpoint connection. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, scopeName, privateEndpointConnectionName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, scopeName, privateEndpointConnectionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByPrivateLinkScopeWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPrivateLinkScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, string privateEndpointConnectionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + if (privateEndpointConnectionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointConnectionName"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("privateEndpointConnectionName", privateEndpointConnectionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByPrivateLinkScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPrivateLinkScopeNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateEndpointConnectionsOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateEndpointConnectionsOperationsExtensions.cs new file mode 100644 index 000000000000..f154ba186236 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateEndpointConnectionsOperationsExtensions.cs @@ -0,0 +1,331 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateEndpointConnectionsOperations. + /// + public static partial class PrivateEndpointConnectionsOperationsExtensions + { + /// + /// Gets a private endpoint connection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + public static PrivateEndpointConnection Get(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName) + { + return operations.GetAsync(resourceGroupName, scopeName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Gets a private endpoint connection. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, scopeName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + public static PrivateEndpointConnection CreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName, PrivateEndpointConnection parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, scopeName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, scopeName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + public static void Delete(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName) + { + operations.DeleteAsync(resourceGroupName, scopeName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, scopeName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + public static IPage ListByPrivateLinkScope(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName) + { + return operations.ListByPrivateLinkScopeAsync(resourceGroupName, scopeName).GetAwaiter().GetResult(); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPrivateLinkScopeAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPrivateLinkScopeWithHttpMessagesAsync(resourceGroupName, scopeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + public static PrivateEndpointConnection BeginCreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName, PrivateEndpointConnection parameters) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, scopeName, privateEndpointConnectionName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName, PrivateEndpointConnection parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, scopeName, privateEndpointConnectionName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + public static void BeginDelete(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName) + { + operations.BeginDeleteAsync(resourceGroupName, scopeName, privateEndpointConnectionName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private endpoint connection. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string scopeName, string privateEndpointConnectionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, scopeName, privateEndpointConnectionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByPrivateLinkScopeNext(this IPrivateEndpointConnectionsOperations operations, string nextPageLink) + { + return operations.ListByPrivateLinkScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPrivateLinkScopeNextAsync(this IPrivateEndpointConnectionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPrivateLinkScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkResourcesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkResourcesOperations.cs new file mode 100644 index 000000000000..19abc53f2f06 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkResourcesOperations.cs @@ -0,0 +1,663 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkResourcesOperations operations. + /// + internal partial class PrivateLinkResourcesOperations : IServiceOperations, IPrivateLinkResourcesOperations + { + /// + /// Initializes a new instance of the PrivateLinkResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateLinkResourcesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByPrivateLinkScopeWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPrivateLinkScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private link resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string scopeName, string groupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + if (groupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupName"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("groupName", groupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + _url = _url.Replace("{groupName}", System.Uri.EscapeDataString(groupName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByPrivateLinkScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPrivateLinkScopeNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkResourcesOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..60ce383a270c --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkResourcesOperationsExtensions.cs @@ -0,0 +1,151 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateLinkResourcesOperations. + /// + public static partial class PrivateLinkResourcesOperationsExtensions + { + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + public static IPage ListByPrivateLinkScope(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string scopeName) + { + return operations.ListByPrivateLinkScopeAsync(resourceGroupName, scopeName).GetAwaiter().GetResult(); + } + + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPrivateLinkScopeAsync(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string scopeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPrivateLinkScopeWithHttpMessagesAsync(resourceGroupName, scopeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private link resource. + /// + public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string scopeName, string groupName) + { + return operations.GetAsync(resourceGroupName, scopeName, groupName).GetAwaiter().GetResult(); + } + + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the private link resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateLinkResourcesOperations operations, string resourceGroupName, string scopeName, string groupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, scopeName, groupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByPrivateLinkScopeNext(this IPrivateLinkResourcesOperations operations, string nextPageLink) + { + return operations.ListByPrivateLinkScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets the private link resources that need to be created for a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPrivateLinkScopeNextAsync(this IPrivateLinkResourcesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPrivateLinkScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopeOperationStatusOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopeOperationStatusOperations.cs new file mode 100644 index 000000000000..4ff6cb960b4d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopeOperationStatusOperations.cs @@ -0,0 +1,267 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkScopeOperationStatusOperations operations. + /// + internal partial class PrivateLinkScopeOperationStatusOperations : IServiceOperations, IPrivateLinkScopeOperationStatusOperations + { + /// + /// Initializes a new instance of the PrivateLinkScopeOperationStatusOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateLinkScopeOperationStatusOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Get the status of an azure asynchronous operation associated with a private + /// link scope operation. + /// + /// + /// The operation Id. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string asyncOperationId, string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (asyncOperationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "asyncOperationId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("asyncOperationId", asyncOperationId); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}").ToString(); + _url = _url.Replace("{asyncOperationId}", System.Uri.EscapeDataString(asyncOperationId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopeOperationStatusOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopeOperationStatusOperationsExtensions.cs new file mode 100644 index 000000000000..67cfc122b2a1 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopeOperationStatusOperationsExtensions.cs @@ -0,0 +1,67 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateLinkScopeOperationStatusOperations. + /// + public static partial class PrivateLinkScopeOperationStatusOperationsExtensions + { + /// + /// Get the status of an azure asynchronous operation associated with a private + /// link scope operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The operation Id. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + public static OperationStatus Get(this IPrivateLinkScopeOperationStatusOperations operations, string asyncOperationId, string resourceGroupName) + { + return operations.GetAsync(asyncOperationId, resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get the status of an azure asynchronous operation associated with a private + /// link scope operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The operation Id. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateLinkScopeOperationStatusOperations operations, string asyncOperationId, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(asyncOperationId, resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopedResourcesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopedResourcesOperations.cs new file mode 100644 index 000000000000..c7f8454f078d --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopedResourcesOperations.cs @@ -0,0 +1,1167 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkScopedResourcesOperations operations. + /// + internal partial class PrivateLinkScopedResourcesOperations : IServiceOperations, IPrivateLinkScopedResourcesOperations + { + /// + /// Initializes a new instance of the PrivateLinkScopedResourcesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateLinkScopedResourcesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Gets a scoped resource in a private link scope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The resource id of the scoped Azure monitor resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, string linkedResourceId = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, scopeName, name, linkedResourceId, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, scopeName, name, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByPrivateLinkScopeWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPrivateLinkScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The resource id of the scoped Azure monitor resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, string linkedResourceId = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2019-10-17-preview"; + ScopedResource parameters = new ScopedResource(); + if (linkedResourceId != null) + { + parameters.LinkedResourceId = linkedResourceId; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("name", name); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, string name, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + if (name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "name"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("name", name); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + _url = _url.Replace("{name}", System.Uri.EscapeDataString(name)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByPrivateLinkScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPrivateLinkScopeNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopedResourcesOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopedResourcesOperationsExtensions.cs new file mode 100644 index 000000000000..9d1eb0b2ef67 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopedResourcesOperationsExtensions.cs @@ -0,0 +1,335 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateLinkScopedResourcesOperations. + /// + public static partial class PrivateLinkScopedResourcesOperationsExtensions + { + /// + /// Gets a scoped resource in a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + public static ScopedResource Get(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name) + { + return operations.GetAsync(resourceGroupName, scopeName, name).GetAwaiter().GetResult(); + } + + /// + /// Gets a scoped resource in a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, scopeName, name, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The resource id of the scoped Azure monitor resource. + /// + public static ScopedResource CreateOrUpdate(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name, string linkedResourceId = default(string)) + { + return operations.CreateOrUpdateAsync(resourceGroupName, scopeName, name, linkedResourceId).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The resource id of the scoped Azure monitor resource. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name, string linkedResourceId = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, scopeName, name, linkedResourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + public static void Delete(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name) + { + operations.DeleteAsync(resourceGroupName, scopeName, name).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, scopeName, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + public static IPage ListByPrivateLinkScope(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName) + { + return operations.ListByPrivateLinkScopeAsync(resourceGroupName, scopeName).GetAwaiter().GetResult(); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPrivateLinkScopeAsync(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPrivateLinkScopeWithHttpMessagesAsync(resourceGroupName, scopeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The resource id of the scoped Azure monitor resource. + /// + public static ScopedResource BeginCreateOrUpdate(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name, string linkedResourceId = default(string)) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, scopeName, name, linkedResourceId).GetAwaiter().GetResult(); + } + + /// + /// Approve or reject a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The resource id of the scoped Azure monitor resource. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name, string linkedResourceId = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, scopeName, name, linkedResourceId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + public static void BeginDelete(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name) + { + operations.BeginDeleteAsync(resourceGroupName, scopeName, name).GetAwaiter().GetResult(); + } + + /// + /// Deletes a private endpoint connection with a given name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The name of the scoped resource object. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPrivateLinkScopedResourcesOperations operations, string resourceGroupName, string scopeName, string name, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, scopeName, name, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByPrivateLinkScopeNext(this IPrivateLinkScopedResourcesOperations operations, string nextPageLink) + { + return operations.ListByPrivateLinkScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all private endpoint connections on a private link scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPrivateLinkScopeNextAsync(this IPrivateLinkScopedResourcesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPrivateLinkScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopesOperations.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopesOperations.cs new file mode 100644 index 000000000000..198c94b8b6c3 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopesOperations.cs @@ -0,0 +1,1690 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PrivateLinkScopesOperations operations. + /// + internal partial class PrivateLinkScopesOperations : IServiceOperations, IPrivateLinkScopesOperations + { + /// + /// Initializes a new instance of the PrivateLinkScopesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PrivateLinkScopesOperations(MonitorManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the MonitorManagementClient + /// + public MonitorManagementClient Client { get; private set; } + + /// + /// Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a list of Azure Monitor PrivateLinkScopes within a resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a Azure Monitor PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, scopeName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Returns a Azure Monitor PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot + /// specify a different value for InstrumentationKey nor AppId in the Put + /// operation. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Properties that need to be specified to create or update a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string scopeName, AzureMonitorPrivateLinkScope azureMonitorPrivateLinkScopePayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + if (azureMonitorPrivateLinkScopePayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "azureMonitorPrivateLinkScopePayload"); + } + if (azureMonitorPrivateLinkScopePayload != null) + { + azureMonitorPrivateLinkScopePayload.Validate(); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("azureMonitorPrivateLinkScopePayload", azureMonitorPrivateLinkScopePayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(azureMonitorPrivateLinkScopePayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(azureMonitorPrivateLinkScopePayload, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates an existing PrivateLinkScope's tags. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Resource tags + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateTagsWithHttpMessagesAsync(string resourceGroupName, string scopeName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + string apiVersion = "2019-10-17-preview"; + TagsResource privateLinkScopeTags = new TagsResource(); + if (tags != null) + { + privateLinkScopeTags.Tags = tags; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("privateLinkScopeTags", privateLinkScopeTags); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UpdateTags", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(privateLinkScopeTags != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(privateLinkScopeTags, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a Azure Monitor PrivateLinkScope. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string scopeName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.SubscriptionId != null) + { + if (Client.SubscriptionId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "Client.SubscriptionId", 1); + } + } + if (scopeName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scopeName"); + } + string apiVersion = "2019-10-17-preview"; + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("apiVersion", apiVersion); + tracingParameters.Add("scopeName", scopeName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{scopeName}", System.Uri.EscapeDataString(scopeName)); + List _queryParameters = new List(); + if (apiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a list of Azure Monitor PrivateLinkScopes within a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopesOperationsExtensions.cs b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopesOperationsExtensions.cs new file mode 100644 index 000000000000..775786a5a3c9 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/PrivateLinkScopesOperationsExtensions.cs @@ -0,0 +1,371 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PrivateLinkScopesOperations. + /// + public static partial class PrivateLinkScopesOperationsExtensions + { + /// + /// Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IPrivateLinkScopesOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IPrivateLinkScopesOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a list of Azure Monitor PrivateLinkScopes within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + public static IPage ListByResourceGroup(this IPrivateLinkScopesOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of Azure Monitor PrivateLinkScopes within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IPrivateLinkScopesOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a Azure Monitor PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + public static void Delete(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName) + { + operations.DeleteAsync(resourceGroupName, scopeName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a Azure Monitor PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, scopeName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Returns a Azure Monitor PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + public static AzureMonitorPrivateLinkScope Get(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName) + { + return operations.GetAsync(resourceGroupName, scopeName).GetAwaiter().GetResult(); + } + + /// + /// Returns a Azure Monitor PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, scopeName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot + /// specify a different value for InstrumentationKey nor AppId in the Put + /// operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Properties that need to be specified to create or update a Azure Monitor + /// PrivateLinkScope. + /// + public static AzureMonitorPrivateLinkScope CreateOrUpdate(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, AzureMonitorPrivateLinkScope azureMonitorPrivateLinkScopePayload) + { + return operations.CreateOrUpdateAsync(resourceGroupName, scopeName, azureMonitorPrivateLinkScopePayload).GetAwaiter().GetResult(); + } + + /// + /// Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot + /// specify a different value for InstrumentationKey nor AppId in the Put + /// operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Properties that need to be specified to create or update a Azure Monitor + /// PrivateLinkScope. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, AzureMonitorPrivateLinkScope azureMonitorPrivateLinkScopePayload, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, scopeName, azureMonitorPrivateLinkScopePayload, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates an existing PrivateLinkScope's tags. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Resource tags + /// + public static AzureMonitorPrivateLinkScope UpdateTags(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateTagsAsync(resourceGroupName, scopeName, tags).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing PrivateLinkScope's tags. To update other fields use the + /// CreateOrUpdate method. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// Resource tags + /// + /// + /// The cancellation token. + /// + public static async Task UpdateTagsAsync(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateTagsWithHttpMessagesAsync(resourceGroupName, scopeName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a Azure Monitor PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + public static void BeginDelete(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName) + { + operations.BeginDeleteAsync(resourceGroupName, scopeName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a Azure Monitor PrivateLinkScope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the Azure Monitor PrivateLinkScope resource. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPrivateLinkScopesOperations operations, string resourceGroupName, string scopeName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, scopeName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IPrivateLinkScopesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IPrivateLinkScopesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a list of Azure Monitor PrivateLinkScopes within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IPrivateLinkScopesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a list of Azure Monitor PrivateLinkScopes within a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IPrivateLinkScopesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Generated/SdkInfo_MonitorManagementClient.cs b/src/Monitor/Monitor.Management.Sdk/Generated/SdkInfo_MonitorManagementClient.cs new file mode 100644 index 000000000000..14838a1b84cb --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Generated/SdkInfo_MonitorManagementClient.cs @@ -0,0 +1,43 @@ + +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Monitor +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_MonitorManagementClient + { + get + { + return new Tuple[] + { + new Tuple("Insights", "ActivityLogs", "2015-04-01"), + new Tuple("Insights", "AlertRules", "2016-03-01"), + new Tuple("Insights", "AutoscaleSettings", "2015-04-01"), + new Tuple("Insights", "Baselines", "2019-03-01"), + new Tuple("Insights", "DiagnosticSettings", "2017-05-01-preview"), + new Tuple("Insights", "EventCategories", "2015-04-01"), + new Tuple("Insights", "LogProfiles", "2016-03-01"), + new Tuple("Insights", "MetricAlerts", "2018-03-01"), + new Tuple("Insights", "MetricAlertsStatus", "2018-03-01"), + new Tuple("Insights", "MetricDefinitions", "2018-01-01"), + new Tuple("Insights", "Metrics", "2018-01-01"), + new Tuple("Insights", "PrivateEndpointConnections", "2019-10-17-preview"), + new Tuple("Insights", "PrivateLinkResources", "2019-10-17-preview"), + new Tuple("Insights", "PrivateLinkScopedResources", "2019-10-17-preview"), + new Tuple("insights", "MetricNamespaces", "2017-12-01-preview"), + new Tuple("insights", "PrivateLinkScopeOperationStatus", "2019-10-17-preview"), + new Tuple("insights", "PrivateLinkScopes", "2019-10-17-preview"), + }.AsEnumerable(); + } + } + } +} diff --git a/src/Monitor/Monitor.Management.Sdk/Monitor.Management.Sdk.csproj b/src/Monitor/Monitor.Management.Sdk/Monitor.Management.Sdk.csproj new file mode 100644 index 000000000000..b7a4905a0e66 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Monitor.Management.Sdk.csproj @@ -0,0 +1,13 @@ + + + Monitor + + + + netstandard2.0 + Microsoft.Azure.PowerShell.Monitor.Management.Sdk + Microsoft.Azure.Management.Monitor + $(NoWarn);CS0108;CS1573 + + + \ No newline at end of file diff --git a/src/Monitor/Monitor.Management.Sdk/Properties/AssemblyInfo.cs b/src/Monitor/Monitor.Management.Sdk/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..e5c68a38cdd1 --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +// ---------------------------------------------------------------------------------- +// +// 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.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Microsoft Azure Powershell - Monitor Management SDK")] +[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] +[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] +[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] + +[assembly: AssemblyVersion("0.28.0.0")] +[assembly: AssemblyFileVersion("0.28.0.0")] \ No newline at end of file diff --git a/src/Monitor/Monitor.Management.Sdk/README.md b/src/Monitor/Monitor.Management.Sdk/README.md new file mode 100644 index 000000000000..8b7cca548afe --- /dev/null +++ b/src/Monitor/Monitor.Management.Sdk/README.md @@ -0,0 +1,123 @@ +# Overall +This directory contains management plane service clients of Az.Monitor module. + +## Run Generation +In this directory, run AutoRest: +``` +autorest --reset +autorest --use:@microsoft.azure/autorest.csharp@2.3.90 +autorest.cmd README.md --version=v2 +``` + +### AutoRest Configuration +> see https://aka.ms/autorest +``` yaml +csharp: true +clear-output-folder: true +reflect-api-versions: true +openapi-type: arm +azure-arm: true +license-header: MICROSOFT_MIT_NO_VERSION +title: MonitorManagementClient +description: Monitor Management Client +payload-flattening-threshold: 1 +``` + +### +``` yaml +commit: 92cf370fd73318f3cf92c36403274ba695873857 +input-file: + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/autoscale_API.json + # - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/operations_API.json + # - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/alertRulesIncidents_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/alertRules_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/logProfiles_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/diagnosticsSettings_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/activityLogs_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/eventCategories_API.json + # - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/tenantActivityLogs_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2019-03-01/metricBaselines_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/metricAlert_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-12-01-preview/metricNamespaces_API.json + # - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/preview/2018-11-27-preview/vmInsightsOnboarding_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/monitor/resource-manager/Microsoft.Insights/preview/2019-10-17-preview/privateLinkScopes_API.json + +output-folder: Generated + +namespace: Microsoft.Azure.Management.Monitor + +directive: + - suppress: Example Validations + reason: There are open issues (bugs) in the validator affecting some of the examples and since there is no way to selectively disable the validation for a particular example or paths, all of the example validation is being turned off. + - suppress: R4009 + from: privateLinkScopes_API.json + reason: 'Contract is defined in the Network RP private endpoint spec, can be updated by internal calls from Network RP. ' + - suppress: R3018 + from: privateLinkScopes_API.json + where: $.definitions.PrivateEndpointConnectionProperties.properties.queryOnlyPrivateLinkResources + reason: 'This property indicates whether data coming through this private endpoint should restrict itself only to resources in the scope - it has only ''''true'''' or ''''false'''' options, so it fits boolean type.' + - suppress: R3018 + from: privateLinkScopes_API.json + where: $.definitions.PrivateEndpointConnectionProperties.properties.ingestOnlyToPrivateLinkResources + reason: 'This property indicates whether data coming through this private endpoint should restrict itself only to resources in the scope - it has only ''''true'''' or ''''false'''' options, so it fits boolean type.' + - suppress: OperationsAPIImplementation + from: privateLinkScopes_API.json + where: $.paths + reason: 'Operations API is defined in a separate swagger spec for Microsoft.Insights namespace (https://github.com/Azure/azure-rest-api-specs/blob/master/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/operations_API.json)' + - suppress: R3016 + reason: The feature (polymorphic types) is in the process of deprecation and fixing this will require changes in the backend. + + - suppress: MissingTypeObject + from: metrics_API.json + where: $.definitions.LocalizableString + reason: 'LocalizableString exists in other swaggers my team can not modify' + - suppress: MissingTypeObject + from: metricDefinitions_API.json + where: $.definitions.LocalizableString + reason: 'LocalizableString exists in other swaggers my team can not modify' + - suppress: OperationsAPIImplementation + where: $.paths + from: activityLogAlerts_API.json + reason: 'Operations API is defined in a separate swagger spec for Microsoft.Insights namespace (https://github.com/Azure/azure-rest-api-specs/blob/master/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/operations_API.json)' + - suppress: R3016 + where: $.definitions.Action.properties["odata.type"] + reason: 'This is an old field in a stable api version which is not camel cased' + - suppress: EnumInsteadOfBoolean + where: $.definitions.AlertRuleProperties.properties.enabled + from: activityLogAlerts_API.json + reason: 'This property indicates whether the alert rule is enabled or not - it has only ''''true'''' or ''''false'''' options, so it fits boolean type.' + - suppress: EnumInsteadOfBoolean + where: $.definitions.AlertRulePatchProperties.properties.enabled + from: activityLogAlerts_API.json + reason: 'This property indicates whether the alert rule is enabled or not - it has only ''''true'''' or ''''false'''' options, so it fits boolean type.' + - suppress: DefaultErrorResponseSchema + from: activityLogAlerts_API.json + reason: 'Updating the error response to the new format would be a breaking change.' + - suppress: DefaultErrorResponseSchema + from: metricNamespaces_API.json + reason: 'Updating the error response to the new format would be a breaking change.' + - suppress: DefaultErrorResponseSchema + from: metrics_API.json + reason: 'Updating the error response to the new format would be a breaking change.' + - suppress: DefaultErrorResponseSchema + from: metricDefinitions_API.json + reason: 'Updating the error response to the new format would be a breaking change.' + - suppress: OperationsAPIImplementation + from: operations_API.json + where: $.paths + reason: 'The operations API is implemented however the tool is still firing due to the casing being different' + - suppress: OperationsAPIImplementation + from: serviceDiagnosticsSettings_API.json + where: $.paths + reason: 'Operations API is defined in a separate swagger spec for Microsoft.Insights namespace (https://github.com/Azure/azure-rest-api-specs/blob/master/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/operations_API.json)' + - suppress: OperationsAPIImplementation + from: subscriptionDiagnosticsSettings_API.json + where: $.paths + reason: 'Operations API is defined in a separate swagger spec for Microsoft.Insights namespace (https://github.com/Azure/azure-rest-api-specs/blob/master/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/operations_API.json)' + - suppress: OperationsAPIImplementation + from: autoscale_API.json + where: $.paths + reason: 'Operations API is defined in a separate swagger spec for Microsoft.Insights namespace (https://github.com/Azure/azure-rest-api-specs/blob/master/specification/monitor/resource-manager/Microsoft.Insights/stable/2015-04-01/operations_API.json)' +``` \ No newline at end of file diff --git a/src/Monitor/Monitor.Test/Monitor.Test.csproj b/src/Monitor/Monitor.Test/Monitor.Test.csproj index 27edf5cb975d..82528048ec9f 100644 --- a/src/Monitor/Monitor.Test/Monitor.Test.csproj +++ b/src/Monitor/Monitor.Test/Monitor.Test.csproj @@ -11,12 +11,12 @@ - + diff --git a/src/Monitor/Monitor.sln b/src/Monitor/Monitor.sln index 79eef3a3ca34..d0e1c0832713 100644 --- a/src/Monitor/Monitor.sln +++ b/src/Monitor/Monitor.sln @@ -5,64 +5,63 @@ VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Accounts", "Accounts", "{EAA233B5-64B2-4DB0-991A-DD490E0B252B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accounts", "..\Accounts\Accounts\Accounts.csproj", "{99E9B517-1C84-47CA-8364-F4F1C25EC656}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Accounts", "..\Accounts\Accounts\Accounts.csproj", "{99E9B517-1C84-47CA-8364-F4F1C25EC656}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyLoading", "..\Accounts\AssemblyLoading\AssemblyLoading.csproj", "{515B67FA-011D-4114-B476-B814F716F158}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyLoading", "..\Accounts\AssemblyLoading\AssemblyLoading.csproj", "{515B67FA-011D-4114-B476-B814F716F158}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authentication.ResourceManager", "..\Accounts\Authentication.ResourceManager\Authentication.ResourceManager.csproj", "{1304DFB0-29F5-4F7C-BB03-FF0EE7E5E5A2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication.ResourceManager", "..\Accounts\Authentication.ResourceManager\Authentication.ResourceManager.csproj", "{1304DFB0-29F5-4F7C-BB03-FF0EE7E5E5A2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authentication", "..\Accounts\Authentication\Authentication.csproj", "{4DEBFCC2-E377-4CFA-8459-F5670417F0C1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication", "..\Accounts\Authentication\Authentication.csproj", "{4DEBFCC2-E377-4CFA-8459-F5670417F0C1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthenticationAssemblyLoadContext", "..\Accounts\AuthenticationAssemblyLoadContext\AuthenticationAssemblyLoadContext.csproj", "{39840772-D709-4858-A5FF-C003DDE4C322}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AuthenticationAssemblyLoadContext", "..\Accounts\AuthenticationAssemblyLoadContext\AuthenticationAssemblyLoadContext.csproj", "{39840772-D709-4858-A5FF-C003DDE4C322}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authenticators", "..\Accounts\Authenticators\Authenticators.csproj", "{E7AC7E3A-B8F8-485B-ABD4-1406F7C43782}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authenticators", "..\Accounts\Authenticators\Authenticators.csproj", "{E7AC7E3A-B8F8-485B-ABD4-1406F7C43782}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{3F76A15C-B128-4A31-A887-05E303CF8D7F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DependentModules", "DependentModules", "{5E1B5E7C-8C9C-47AD-8F8F-19628E8D1B34}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.ApplicationInsights", "..\ApplicationInsights\ApplicationInsights.Autorest\Az.ApplicationInsights.csproj", "{BE7CCFEE-61D5-4F38-8DDA-548DCE8C4923}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.ApplicationInsights", "..\ApplicationInsights\ApplicationInsights.Autorest\Az.ApplicationInsights.csproj", "{BE7CCFEE-61D5-4F38-8DDA-548DCE8C4923}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationInsights", "..\ApplicationInsights\ApplicationInsights\ApplicationInsights.csproj", "{6219CD72-2EF8-4905-A293-CFAF4942130F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationInsights", "..\ApplicationInsights\ApplicationInsights\ApplicationInsights.csproj", "{6219CD72-2EF8-4905-A293-CFAF4942130F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.ActionGroup", "ActionGroup.Autorest\Az.ActionGroup.csproj", "{55BCFF14-EE0A-4D14-9294-CE78300ACBE8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.ActionGroup", "ActionGroup.Autorest\Az.ActionGroup.csproj", "{55BCFF14-EE0A-4D14-9294-CE78300ACBE8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.ActivityLogAlert", "ActivityLogAlert.Autorest\Az.ActivityLogAlert.csproj", "{0B76BAD3-775A-4017-8F0C-1C0F1B8D4518}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.ActivityLogAlert", "ActivityLogAlert.Autorest\Az.ActivityLogAlert.csproj", "{0B76BAD3-775A-4017-8F0C-1C0F1B8D4518}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.Autoscale", "Autoscale.Autorest\Az.Autoscale.csproj", "{0195E501-0C9A-46CA-A54D-6B9056413593}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.Autoscale", "Autoscale.Autorest\Az.Autoscale.csproj", "{0195E501-0C9A-46CA-A54D-6B9056413593}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.DataCollectionRule", "DataCollectionRule.Autorest\Az.DataCollectionRule.csproj", "{CC45538E-D624-4E9F-8900-98E103CF3402}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.DataCollectionRule", "DataCollectionRule.Autorest\Az.DataCollectionRule.csproj", "{CC45538E-D624-4E9F-8900-98E103CF3402}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.DiagnosticSetting", "DiagnosticSetting.Autorest\Az.DiagnosticSetting.csproj", "{DB4B8515-7711-4C57-986D-B8085DB90ADD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.DiagnosticSetting", "DiagnosticSetting.Autorest\Az.DiagnosticSetting.csproj", "{DB4B8515-7711-4C57-986D-B8085DB90ADD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monitor.Test", "Monitor.Test\Monitor.Test.csproj", "{D5C30947-FBD5-4185-8240-7D8527A0C13C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monitor.Test", "Monitor.Test\Monitor.Test.csproj", "{D5C30947-FBD5-4185-8240-7D8527A0C13C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monitor", "Monitor\Monitor.csproj", "{07DBB93E-C011-4AFD-AD30-5E9688A6A026}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monitor", "Monitor\Monitor.csproj", "{07DBB93E-C011-4AFD-AD30-5E9688A6A026}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.MonitorWorkspace", "MonitorWorkspace.Autorest\Az.MonitorWorkspace.csproj", "{FDA456F4-19EC-45AC-A1D7-363D4000EFCD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.MonitorWorkspace", "MonitorWorkspace.Autorest\Az.MonitorWorkspace.csproj", "{FDA456F4-19EC-45AC-A1D7-363D4000EFCD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.ScheduledQueryRule", "ScheduledQueryRule.Autorest\Az.ScheduledQueryRule.csproj", "{AA04E3D0-0173-477D-86E8-794DC601F032}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.ScheduledQueryRule", "ScheduledQueryRule.Autorest\Az.ScheduledQueryRule.csproj", "{AA04E3D0-0173-477D-86E8-794DC601F032}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Network.Management.Sdk", "..\Network\Network.Management.Sdk\Network.Management.Sdk.csproj", "{5A8422A0-17A6-4CC3-8C33-5C44059BA64E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Network.Management.Sdk", "..\Network\Network.Management.Sdk\Network.Management.Sdk.csproj", "{5A8422A0-17A6-4CC3-8C33-5C44059BA64E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Network", "..\Network\Network\Network.csproj", "{DE5F414C-83E4-4F3E-9BAC-0D6921873B36}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Network", "..\Network\Network\Network.csproj", "{DE5F414C-83E4-4F3E-9BAC-0D6921873B36}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OperationalInsights", "..\OperationalInsights\OperationalInsights\OperationalInsights.csproj", "{B54BD1A5-F4AB-485B-8478-520B6AA1E9E7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OperationalInsights", "..\OperationalInsights\OperationalInsights\OperationalInsights.csproj", "{B54BD1A5-F4AB-485B-8478-520B6AA1E9E7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestFx", "..\..\tools\TestFx\TestFx.csproj", "{0636EEB2-FE81-4424-8CFC-CCEB25360A40}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFx", "..\..\tools\TestFx\TestFx.csproj", "{0636EEB2-FE81-4424-8CFC-CCEB25360A40}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.Metricdata", "MetricData.Autorest\Az.Metricdata.csproj", "{F95B32A7-D021-418F-9AC3-33D1A3CAE39C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.Metricdata", "MetricData.Autorest\Az.Metricdata.csproj", "{F95B32A7-D021-418F-9AC3-33D1A3CAE39C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.PipelineGroup", "PipelineGroup.Autorest\Az.PipelineGroup.csproj", "{25911606-03C7-40C4-AA27-C7F1230040B6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.PipelineGroup", "PipelineGroup.Autorest\Az.PipelineGroup.csproj", "{25911606-03C7-40C4-AA27-C7F1230040B6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monitor.Management.Sdk", "Monitor.Management.Sdk\Monitor.Management.Sdk.csproj", "{55719D82-53E9-4CEA-9532-5E72BB0025EA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {99E9B517-1C84-47CA-8364-F4F1C25EC656}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {99E9B517-1C84-47CA-8364-F4F1C25EC656}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -156,6 +155,13 @@ Global {25911606-03C7-40C4-AA27-C7F1230040B6}.Debug|Any CPU.Build.0 = Debug|Any CPU {25911606-03C7-40C4-AA27-C7F1230040B6}.Release|Any CPU.ActiveCfg = Release|Any CPU {25911606-03C7-40C4-AA27-C7F1230040B6}.Release|Any CPU.Build.0 = Release|Any CPU + {55719D82-53E9-4CEA-9532-5E72BB0025EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55719D82-53E9-4CEA-9532-5E72BB0025EA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55719D82-53E9-4CEA-9532-5E72BB0025EA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55719D82-53E9-4CEA-9532-5E72BB0025EA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {99E9B517-1C84-47CA-8364-F4F1C25EC656} = {EAA233B5-64B2-4DB0-991A-DD490E0B252B} diff --git a/src/Monitor/Monitor/Az.Monitor.psd1 b/src/Monitor/Monitor/Az.Monitor.psd1 index c76fb4e44c21..3829b6acf09b 100644 --- a/src/Monitor/Monitor/Az.Monitor.psd1 +++ b/src/Monitor/Monitor/Az.Monitor.psd1 @@ -62,7 +62,7 @@ RequiredAssemblies = 'ActionGroup.Autorest/bin/Az.ActionGroup.private.dll', 'DataCollectionRule.Autorest/bin/Az.DataCollectionRule.private.dll', 'DiagnosticSetting.Autorest/bin/Az.DiagnosticSetting.private.dll', 'MetricData.Autorest/bin/Az.Metricdata.private.dll', - 'Microsoft.Azure.Management.Monitor.dll', + 'Microsoft.Azure.PowerShell.Monitor.Management.Sdk.dll', 'MonitorWorkspace.Autorest/bin/Az.MonitorWorkspace.private.dll', 'PipelineGroup.Autorest/bin/Az.PipelineGroup.private.dll', 'ScheduledQueryRule.Autorest/bin/Az.ScheduledQueryRule.private.dll' diff --git a/src/Monitor/Monitor/Monitor.csproj b/src/Monitor/Monitor/Monitor.csproj index 7063d72894b9..e343d0a82ac6 100644 --- a/src/Monitor/Monitor/Monitor.csproj +++ b/src/Monitor/Monitor/Monitor.csproj @@ -10,10 +10,10 @@ $(LegacyAssemblyPrefix)Insights + + - + - - diff --git a/src/Monitor/Monitor/OutputClasses/PSActionGroupProperty.cs b/src/Monitor/Monitor/OutputClasses/PSActionGroupProperty.cs deleted file mode 100644 index a1024d35eaa4..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSActionGroupProperty.cs +++ /dev/null @@ -1,116 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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.Collections.Generic; -using System.Linq; - -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - - - /// - /// Wraps around the action group. - /// - public class PSActionGroupProperty : PSManagementPropertyDescriptor - { - /// - /// Gets or sets the action group status. - /// - public string Status { get; set; } - - /// - /// Gets or sets the action group short name. - /// - public string GroupShortName { get; set; } - - /// - /// Gets or sets the list of email receivers. - /// - public IList EmailReceivers { get; set; } - - /// - /// Gets or sets the list of SMS receivers. - /// - public IList SmsReceivers { get; set; } - - /// - /// Gets or sets the list of webhook receviers. - /// - public IList WebhookReceivers { get; set; } - - /// - /// Gets or sets the list of event hub receviers. - /// - public IList EventHubReceivers { get; set; } - - /// - /// Gets or sets the list of itsm receviers. - /// - public IList ItsmReceivers { get; set; } - - /// - /// Gets or sets the list of voice receviers. - /// - public IList VoiceReceivers { get; set; } - - /// - /// Gets or sets the list of armrole receviers. - /// - public IList ArmRoleReceivers { get; set; } - - /// - /// Gets or sets the list of azure function receviers. - /// - public IList AzureFunctionReceivers { get; set; } - - /// - /// Gets or sets the list of logic app receviers. - /// - public IList LogicAppReceivers { get; set; } - - /// - /// Gets or sets the list of automation runbook receviers. - /// - public IList AutomationRunbookReceivers { get; set; } - - /// - /// Gets or sets the list of azure app push receviers. - /// - public IList AzureAppPushReceivers { get; set; } - - - /// - /// Initializes a new instance of the PSActionGroupProperty class. - /// - /// The action group to wrap. - public PSActionGroupProperty(ActionGroupResource actionGroup) - { - this.Status = actionGroup.Enabled ? "Enabled" : "Disabled"; - this.GroupShortName = actionGroup.GroupShortName; - this.EmailReceivers = actionGroup.EmailReceivers.Select(e => new PSEmailReceiver(e)).ToList(); - this.SmsReceivers = actionGroup.SmsReceivers.Select(s => new PSSmsReceiver(s)).ToList(); - this.WebhookReceivers = actionGroup.WebhookReceivers.Select(w => new PSWebhookReceiver(w)).ToList(); - this.EventHubReceivers = actionGroup.EventHubReceivers.Select(w => new PSEventHubReceiver(w)).ToList(); - this.ItsmReceivers = actionGroup.ItsmReceivers.Select(w => new PSItsmReceiver(w)).ToList(); - this.VoiceReceivers = actionGroup.VoiceReceivers.Select(w => new PSVoiceReceiver(w)).ToList(); - this.ArmRoleReceivers = actionGroup.ArmRoleReceivers.Select(w => new PSArmRoleReceiver(w)).ToList(); - this.AzureFunctionReceivers = actionGroup.AzureFunctionReceivers.Select(w => new PSAzureFunctionReceiver(w)).ToList(); - this.LogicAppReceivers = actionGroup.LogicAppReceivers.Select(w => new PSLogicAppReceiver(w)).ToList(); - this.AutomationRunbookReceivers = actionGroup.AutomationRunbookReceivers.Select(w => new PSAutomationRunbookReceiver(w)).ToList(); - this.AzureAppPushReceivers = actionGroup.AzureAppPushReceivers.Select(w => new PSAzureAppPushReceiver(w)).ToList(); - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSActionGroupResource.cs b/src/Monitor/Monitor/OutputClasses/PSActionGroupResource.cs deleted file mode 100644 index b60c77fcd08f..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSActionGroupResource.cs +++ /dev/null @@ -1,150 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - using System.Collections.Generic; - using System.Linq; - - using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; - - /// - /// Wraps around an Action Group. - /// - public class PSActionGroupResource : Resource - { - /// Gets or sets resource group - public string ResourceGroupName { get; set; } - - /// - /// Gets or sets the short name of the action group. This will be used - /// in SMS messages. - /// - /// - public string GroupShortName { get; set; } - - /// - /// Gets or sets indicates whether this action group is enabled. If an - /// action group is not enabled, then none of its receviers will - /// receive communications. - /// - /// - public bool Enabled { get; set; } - - /// - /// Gets or sets the list of email receivers that are part of this - /// action group. - /// - /// - public IList EmailReceivers { get; set; } - - /// - /// Gets or sets the list of SMS receivers that are part of this action - /// group. - /// - /// - public IList SmsReceivers { get; set; } - - /// - /// Gets or sets the list of webhook receivers that are part of this - /// action group. - /// - /// - public IList WebhookReceivers { get; set; } - - /// - /// Gets or sets the list of event hub receivers that are part of this - /// action group. - /// - /// - public IList EventHubReceivers { get; set; } - - /// - /// Gets or sets the list of Itsm receivers that are part of this - /// action group. - /// - /// - public IList ItsmReceivers { get; set; } - - /// - /// Gets or sets the list of voice receivers that are part of this - /// action group. - /// - /// - public IList VoiceReceivers { get; set; } - - /// - /// Gets or sets the list of arm role receivers that are part of this - /// action group. - /// - /// - public IList ArmRoleReceivers { get; set; } - - /// - /// Gets or sets the list of AzureFunctionReceivers that are part of this - /// action group. - /// - /// - public IList AzureFunctionReceivers { get; set; } - - /// - /// Gets or sets the list of LogicAppReceivers that are part of this - /// action group. - /// - /// - public IList LogicAppReceivers { get; set; } - - /// - /// Gets or sets the list of AutomationRunbookReceivers that are part of this - /// action group. - /// - /// - public IList AutomationRunbookReceivers { get; set; } - - /// - /// Gets or sets the list of AzureAppPushReceivers that are part of this - /// action group. - /// - /// - public IList AzureAppPushReceivers { get; set; } - - /// Initializes a new instance of the PSActionGroup class. - /// the action group resource - public PSActionGroupResource(ActionGroupResource actionGroupResource) - : base( - location: actionGroupResource.Location, - id: actionGroupResource.Id, - name: actionGroupResource.Name, - type: actionGroupResource.Type, - tags: actionGroupResource.Tags) - { - this.ResourceGroupName = new ResourceIdentifier(actionGroupResource.Id).ResourceGroupName; - GroupShortName = actionGroupResource.GroupShortName; - Enabled = actionGroupResource.Enabled; - EmailReceivers = actionGroupResource.EmailReceivers?.Select(o => new PSEmailReceiver(o)).ToList(); - SmsReceivers = actionGroupResource.SmsReceivers?.Select(o => new PSSmsReceiver(o)).ToList(); - WebhookReceivers = actionGroupResource.WebhookReceivers?.Select(o => new PSWebhookReceiver(o)).ToList(); - EventHubReceivers = actionGroupResource.EventHubReceivers?.Select(o => new PSEventHubReceiver(o)).ToList(); - ArmRoleReceivers = actionGroupResource.ArmRoleReceivers?.Select(o => new PSArmRoleReceiver(o)).ToList(); - ItsmReceivers = actionGroupResource.ItsmReceivers?.Select(o => new PSItsmReceiver(o)).ToList(); - VoiceReceivers = actionGroupResource.VoiceReceivers?.Select(o => new PSVoiceReceiver(o)).ToList(); - AzureFunctionReceivers = actionGroupResource.AzureFunctionReceivers?.Select(o => new PSAzureFunctionReceiver(o)).ToList(); - LogicAppReceivers = actionGroupResource.LogicAppReceivers?.Select(o => new PSLogicAppReceiver(o)).ToList(); - AutomationRunbookReceivers = actionGroupResource.AutomationRunbookReceivers?.Select(o => new PSAutomationRunbookReceiver(o)).ToList(); - AzureAppPushReceivers = actionGroupResource.AzureAppPushReceivers?.Select(o => new PSAzureAppPushReceiver(o)).ToList(); - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSAddActionGroupOperationResponse.cs b/src/Monitor/Monitor/OutputClasses/PSAddActionGroupOperationResponse.cs deleted file mode 100644 index dd0fec54c106..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSAddActionGroupOperationResponse.cs +++ /dev/null @@ -1,25 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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. -// ---------------------------------------------------------------------------------- - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Adds the newly added resource as part of the response. - /// - public class PSAddActionGroupOperationResponse : AzureOperationResponse - { - /// Gets or sets the action group./ - public PSActionGroupResource ActionGroup { get; set; } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSArmRoleReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSArmRoleReceiver.cs deleted file mode 100644 index d018c345c377..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSArmRoleReceiver.cs +++ /dev/null @@ -1,46 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the ArmRoleReceiver class. - /// - public class PSArmRoleReceiver : PSActionGroupReceiverBase - { - /// Gets or sets the role id of this receiver. - public string RoleId { get; set; } - - /// Gets or sets a value indicating whether or not use common alert schema. - public bool UseCommonAlertSchema { get; set; } - - /// Initializes a new instance of the PSArmRoleReceiver class - public PSArmRoleReceiver() - { - } - - /// - /// Initializes a new instance of the PSArmRoleReceiver class. - /// - /// The receiver to wrap. - public PSArmRoleReceiver(ArmRoleReceiver receiver) - { - this.Name = receiver.Name; - this.RoleId = receiver.RoleId; - this.UseCommonAlertSchema = receiver.UseCommonAlertSchema.HasValue ? receiver.UseCommonAlertSchema.Value : false; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSAutomationRunbookReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSAutomationRunbookReceiver.cs deleted file mode 100644 index 6036434ca473..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSAutomationRunbookReceiver.cs +++ /dev/null @@ -1,62 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the AutomationRunbookReceiver class. - /// - public class PSAutomationRunbookReceiver : PSActionGroupReceiverBase - { - /// Gets or sets automation account identifier - public string AutomationAccountId { get; set; } - - /// Gets or sets the name of the runbook. - public string RunbookName { get; set; } - - /// Gets or sets the name of the webhook resource id. - public string WebhookResourceId { get; set; } - - /// Gets or sets a value indicating whether this instance is global runbook - public bool IsGlobalRunbook { get; set; } - - /// Gets or sets a value indicating whether or not use common alert schema. - public bool UseCommonAlertSchema { get; set; } - - /// Gets or sets the URI where webhooks should be sent.. - public string ServiceUri { get; set; } - - /// Initializes a new instance of the PSAutomationRunbookReceiver class - public PSAutomationRunbookReceiver() - { - } - - /// - /// Initializes a new instance of the PSAutomationRunbookReceiver class. - /// - /// The receiver to wrap. - public PSAutomationRunbookReceiver(AutomationRunbookReceiver receiver) - { - this.Name = receiver.Name; - this.AutomationAccountId = receiver.AutomationAccountId; - this.RunbookName = receiver.RunbookName; - this.WebhookResourceId = receiver.WebhookResourceId; - this.IsGlobalRunbook = receiver.IsGlobalRunbook; - this.UseCommonAlertSchema = receiver.UseCommonAlertSchema.HasValue ? receiver.UseCommonAlertSchema.Value : false; - this.ServiceUri = receiver.ServiceUri; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSAutoscaleProfilesList.cs b/src/Monitor/Monitor/OutputClasses/PSAutoscaleProfilesList.cs deleted file mode 100644 index 5849475486bf..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSAutoscaleProfilesList.cs +++ /dev/null @@ -1,37 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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.Collections.Generic; -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wrapps around a list of AutoscaleProfile - /// - public class PSAutoscaleProfilesList : List - { - /// - /// Initializes a new instance of the PSAutoscaleProfilesList class. - /// - /// - public PSAutoscaleProfilesList(IList profiles) - { - if (profiles != null) - { - this.AddRange(profiles); - } - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSAutoscaleSetting.cs b/src/Monitor/Monitor/OutputClasses/PSAutoscaleSetting.cs deleted file mode 100644 index 5fddce7f9f0d..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSAutoscaleSetting.cs +++ /dev/null @@ -1,39 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wrapps around the AutoscaleSettingGetResponse and AutoscaleSettingResource - /// - public class PSAutoscaleSetting : Management.Monitor.Management.Models.AutoscaleSettingResource - { - /// - /// Gets or sets the AutoscaleSettingResourceName of the object. - /// This property hides a property of the super class for it not to be displayed since it is in the process of deprecation - /// - private new string AutoscaleSettingResourceName { get; set; } - - /// - /// Initializes a new instance of the PSAutoscaleSetting class. - /// - /// The autoscale setting spec - public PSAutoscaleSetting(AutoscaleSettingResource autoscaleSettingSpec) - : base(autoscaleSettingSpec) - { - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSAutoscaleSettingNoDetails.cs b/src/Monitor/Monitor/OutputClasses/PSAutoscaleSettingNoDetails.cs deleted file mode 100644 index 46e6253c71b0..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSAutoscaleSettingNoDetails.cs +++ /dev/null @@ -1,33 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wrapps around the AutoscaleSettingGetResponse and AutoscaleSettingResource - /// - public sealed class PSAutoscaleSettingNoDetails : PSAutoscaleSetting - { - /// - /// Initializes a new instance of the PSAutoscaleSetting class. - /// - /// The autoscale setting spec - public PSAutoscaleSettingNoDetails(AutoscaleSettingResource autoscaleSettingSpec) - : base(autoscaleSettingSpec) - { - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSAzureAppPushReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSAzureAppPushReceiver.cs deleted file mode 100644 index 5641857ea8c9..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSAzureAppPushReceiver.cs +++ /dev/null @@ -1,45 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Commands.Insights.TransitionalClasses; -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the AzureAppPushReceiver class. - /// - public class PSAzureAppPushReceiver : PSActionGroupReceiverBase - { - /// - /// Gets or sets the receiver's address. - /// - public string EmailAddress { get; set; } - - /// Initializes a new instance of the PSAzureAppPushReceiver class - public PSAzureAppPushReceiver() - { - } - - /// - /// Initializes a new instance of the PSAzureAppPushReceiver class. - /// - /// The receiver to wrap. - public PSAzureAppPushReceiver(AzureAppPushReceiver receiver) - { - this.Name = receiver.Name; - this.EmailAddress = receiver.EmailAddress; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSAzureFunctionReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSAzureFunctionReceiver.cs deleted file mode 100644 index db2ca48326ca..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSAzureFunctionReceiver.cs +++ /dev/null @@ -1,60 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the AzureFunctionReceiver class. - /// - public class PSAzureFunctionReceiver : PSActionGroupReceiverBase - { - /// - /// Gets or sets the function app resourceId. - /// - public string FunctionAppResourceId { get; set; } - - /// - /// Gets or sets the function name - /// - public string FunctionName { get; set; } - - /// - /// Gets or sets the httpTriggerUrl. - /// - public string HttpTriggerUrl { get; set; } - - /// Gets or sets a value indicating whether or not use common alert schema. - public bool UseCommonAlertSchema { get; set; } - - /// Initializes a new instance of the PSAzureFunctionReceiver class - public PSAzureFunctionReceiver() - { - } - - /// - /// Initializes a new instance of the PSAzureFunctionReceiver class. - /// - /// The receiver to wrap. - public PSAzureFunctionReceiver(AzureFunctionReceiver receiver) - { - this.Name = receiver.Name; - this.FunctionAppResourceId = receiver.FunctionAppResourceId; - this.FunctionName = receiver.FunctionName; - this.HttpTriggerUrl = receiver.HttpTriggerUrl; - this.UseCommonAlertSchema = receiver.UseCommonAlertSchema.HasValue ? receiver.UseCommonAlertSchema.Value : false; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSDataCollectionRuleResource.cs b/src/Monitor/Monitor/OutputClasses/PSDataCollectionRuleResource.cs deleted file mode 100644 index 3783695791f8..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSDataCollectionRuleResource.cs +++ /dev/null @@ -1,658 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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.Collections.Generic; -using System.Linq; -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - #region DCR - Data Collection Rule Resource - - /// - /// Wraps around an Data Collection Rule. - /// - public class PSDataCollectionRuleResource : Resource - { - #region Properties - /// - /// Gets or sets description of the data collection rule. - /// - public string Description { get; set; } - - /// - /// Gets or sets the specification of data sources. - /// This property is optional and can be omitted if the rule is meant - /// to be used via direct calls to the provisioned endpoint. - /// - public PSDataCollectionRuleDataSources DataSources { get; set; } - - /// - /// Gets or sets the specification of destinations. - /// - public PSDataCollectionRuleDestinations Destinations { get; set; } - - /// - /// Gets or sets the specification of data flows. - /// - public IList DataFlows { get; set; } - - /// - /// Gets the resource provisioning state. Possible values include: - /// 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed' - /// - public string ProvisioningState { get; private set; } - - /// - /// Gets resource entity tag (ETag). - /// - public new string Etag { get; private set; } - #endregion - - /// - /// Initializes a new instance of the PSDataCollectionRuleResource class. - /// - public PSDataCollectionRuleResource() - { } - - /// - /// Initializes a new instance of the PSDataCollectionRuleResource class. - /// - /// The DataCollectionRuleResource to wrap. - public PSDataCollectionRuleResource(DataCollectionRuleResource dataCollectionRuleResource) - : base( - location: dataCollectionRuleResource.Location, - id: dataCollectionRuleResource.Id, - name: dataCollectionRuleResource.Name, - type: dataCollectionRuleResource.Type, - tags: dataCollectionRuleResource.Tags) - { - Description = dataCollectionRuleResource.Description; - DataSources = dataCollectionRuleResource.DataSources == null ? new PSDataCollectionRuleDataSources() : - new PSDataCollectionRuleDataSources(dataCollectionRuleResource.DataSources); - Destinations = dataCollectionRuleResource.Destinations == null ? new PSDataCollectionRuleDestinations() : - new PSDataCollectionRuleDestinations(dataCollectionRuleResource.Destinations); - DataFlows = dataCollectionRuleResource.DataFlows?.Select(x => new PSDataFlow(x)).ToList(); - ProvisioningState = dataCollectionRuleResource.ProvisioningState; - Etag = dataCollectionRuleResource.Etag; - } - - internal DataCollectionRuleResource ConvertToApiObject() - { - var dcrDefinitionObject = new DataCollectionRuleResource - { - DataSources = new DataCollectionRuleDataSources(), - Destinations = new DataCollectionRuleDestinations(), - DataFlows = new List() - }; - - if (this.DataSources.PerformanceCounters != null && this.DataSources.PerformanceCounters.Count > 0) - { - dcrDefinitionObject.DataSources.PerformanceCounters = this.DataSources.PerformanceCounters.Select(x => new PerfCounterDataSource( - x.Streams, x.SamplingFrequencyInSeconds, x.CounterSpecifiers, x.Name)).ToList(); - } - - if (this.DataSources.WindowsEventLogs != null && this.DataSources.WindowsEventLogs.Count > 0) - { - dcrDefinitionObject.DataSources.WindowsEventLogs = this.DataSources.WindowsEventLogs.Select(x => new WindowsEventLogDataSource( - x.Streams, x.XPathQueries, x.Name)).ToList(); - } - - if (this.DataSources.Syslog != null && this.DataSources.Syslog.Count > 0) - { - dcrDefinitionObject.DataSources.Syslog = this.DataSources.Syslog.Select(x => new SyslogDataSource( - x.Streams, x.FacilityNames, x.LogLevels, x.Name)).ToList(); - } - - if (this.DataSources.Extensions != null && this.DataSources.Extensions.Count > 0) - { - dcrDefinitionObject.DataSources.Extensions = this.DataSources.Extensions.Select(x => new ExtensionDataSource( - x.ExtensionName, x.Streams, x.ExtensionSettings, x.InputDataSources, x.Name)).ToList(); - } - - if (this.Destinations.LogAnalytics != null && this.Destinations.LogAnalytics.Count > 0) - { - dcrDefinitionObject.Destinations.LogAnalytics = this.Destinations.LogAnalytics.Select(x => new LogAnalyticsDestination( - x.WorkspaceResourceId, x.Name)).ToList(); - } - - if (this.Destinations.AzureMonitorMetrics != null) - { - dcrDefinitionObject.Destinations.AzureMonitorMetrics = new DestinationsSpecAzureMonitorMetrics(this.Destinations.AzureMonitorMetrics.Name); - } - - if (this.DataFlows != null && this.DataFlows.Count > 0) - { - dcrDefinitionObject.DataFlows = this.DataFlows.Select(x => new DataFlow( - x.Streams, x.Destinations)).ToList(); - } - - dcrDefinitionObject.Location = this.Location; - dcrDefinitionObject.Description = this.Description; - dcrDefinitionObject.Tags = this.Tags; - - return dcrDefinitionObject; - } - } - - #endregion - - #region DCR's Data Flow - /// - /// Wraps the DataFlow class. - /// - public class PSDataFlow - { - /// - /// Gets or sets list of streams for this data flow. - /// - public IList Streams { get; set; } - - /// - /// Gets or sets list of destinations for this data flow. - /// - public IList Destinations { get; set; } - - /// - /// Initializes a new instance of the PSDataFlow class. - /// - public PSDataFlow() - { } - - /// - /// Initializes a new instance of the PSDataFlow class. - /// - /// The DataFlow to wrap. - public PSDataFlow(DataFlow dataFlow) - { - Streams = dataFlow.Streams?.Select(x => x).ToList(); - Destinations = dataFlow.Destinations?.Select(x => x).ToList(); - } - } - #endregion - - #region DCR's Destinations - /// - /// Wraps the DataCollectionRuleDestinations class. - /// - public class PSDataCollectionRuleDestinations : PSDestinationsSpec - { - /// - /// Initializes a new instance of the PSDataCollectionRuleDestinations class. - /// - public PSDataCollectionRuleDestinations() : base() - { } - - /// - /// Initializes a new instance of the PSDataCollectionRuleDestinations class. - /// - /// The DataCollectionRuleDestinations to wrap. - public PSDataCollectionRuleDestinations(DataCollectionRuleDestinations dataCollectionRuleDestinations) - : base(dataCollectionRuleDestinations) - { } - } - - /// - /// Wraps the DestinationsSpec class. - /// - public class PSDestinationsSpec - { - /// - /// Gets or sets list of Log Analytics destinations. - /// - public IList LogAnalytics { get; set; } - - /// - /// Gets or sets azure Monitor Metrics destination. - /// - public PSDestinationsSpecAzureMonitorMetrics AzureMonitorMetrics { get; set; } - - /// - /// Initializes a new instance of the PSDestinationsSpec class. - /// - public PSDestinationsSpec() - { } - - /// - /// Initializes a new instance of the PSDestinationsSpec class. - /// - /// The DestinationsSpec to wrap. - public PSDestinationsSpec(DestinationsSpec destinationsSpec) - { - LogAnalytics = destinationsSpec.LogAnalytics?.Select(x => new PSLogAnalyticsDestination(x)).ToList(); - AzureMonitorMetrics = destinationsSpec.AzureMonitorMetrics == null ? new PSDestinationsSpecAzureMonitorMetrics() : - new PSDestinationsSpecAzureMonitorMetrics(destinationsSpec.AzureMonitorMetrics); - } - } - - /// - /// Wraps the DestinationsSpecAzureMonitorMetrics class. - /// - public class PSDestinationsSpecAzureMonitorMetrics : PSAzureMonitorMetricsDestination - { - /// - /// Initializes a new instance of the PSDestinationsSpecAzureMonitorMetrics class. - /// - public PSDestinationsSpecAzureMonitorMetrics() : base() - { } - - /// - /// Initializes a new instance of the PSDestinationsSpecAzureMonitorMetrics class. - /// - /// The DestinationsSpecAzureMonitorMetrics to wrap. - public PSDestinationsSpecAzureMonitorMetrics(DestinationsSpecAzureMonitorMetrics destinationsSpecAzureMonitorMetrics) - : base(destinationsSpecAzureMonitorMetrics) - { } - } - - /// - /// Wraps the AzureMonitorMetricsDestination class. - /// - public class PSAzureMonitorMetricsDestination - { - /// - /// Gets or sets a friendly name for the destination. - /// This name should be unique across all destinations (regardless of - /// type) within the data collection rule. - /// - public string Name { get; set; } - - /// - /// Initializes a new instance of the PSAzureMonitorMetricsDestination class. - /// - public PSAzureMonitorMetricsDestination() - { } - - /// - /// Initializes a new instance of the PSAzureMonitorMetricsDestination class. - /// - /// The AzureMonitorMetricsDestination to wrap. - public PSAzureMonitorMetricsDestination(AzureMonitorMetricsDestination azureMonitorMetricsDestination) - { - Name = azureMonitorMetricsDestination.Name; - } - } - - /// - /// Wraps the LogAnalyticsDestination class. - /// - public class PSLogAnalyticsDestination - { - /// - /// Gets or sets the resource ID of the Log Analytics workspace. - /// - public string WorkspaceResourceId { get; set; } - - /// - /// Gets or sets a friendly name for the destination. - /// This name should be unique across all destinations (regardless of - /// type) within the data collection rule. - /// - public string Name { get; set; } - - /// - /// Initializes a new instance of the PSLogAnalyticsDestination class. - /// - public PSLogAnalyticsDestination() - { } - - /// - /// Initializes a new instance of the PSLogAnalyticsDestination class. - /// - /// The LogAnalyticsDestination to wrap. - public PSLogAnalyticsDestination(LogAnalyticsDestination logAnalyticsDestination) - { - WorkspaceResourceId = logAnalyticsDestination.WorkspaceResourceId; - Name = logAnalyticsDestination.Name; - } - } - #endregion - - #region DCR's Data Sources - /// - /// Wraps the DataCollectionRuleDataSources class. - /// - public class PSDataCollectionRuleDataSources : PSDataSourcesSpec - { - /// - /// Initializes a new instance of the PSDataCollectionRuleDataSources class. - /// - public PSDataCollectionRuleDataSources() - : base() - { } - - /// - /// Initializes a new instance of the PSDataCollectionRuleDataSources class. - /// - /// The DataCollectionRuleDataSources to wrap. - public PSDataCollectionRuleDataSources(DataCollectionRuleDataSources dataCollectionRuleDataSources) - : base(dataCollectionRuleDataSources) - { } - } - - /// - /// Wraps the DataSourcesSpec class. - /// - public class PSDataSourcesSpec - { - /// - /// Gets or sets the list of performance counter data source - /// configurations. - /// - public IList PerformanceCounters { get; set; } - - /// - /// Gets or sets the list of Windows Event Log data source - /// configurations. - /// - public IList WindowsEventLogs { get; set; } - - /// - /// Gets or sets the list of Syslog data source configurations. - /// - public IList Syslog { get; set; } - - /// - /// Gets or sets the list of Azure VM extension data source - /// configurations. - /// - public IList Extensions { get; set; } - - /// - /// Initializes a new instance of the PSDataSourcesSpec class. - /// - public PSDataSourcesSpec() - { } - - /// - /// Initializes a new instance of the PSDataSourcesSpec class. - /// - /// The DataSourcesSpec to wrap. - public PSDataSourcesSpec(DataSourcesSpec dataSourcesSpec) - { - PerformanceCounters = dataSourcesSpec.PerformanceCounters?.Select(x => new PSPerfCounterDataSource(x)).ToList(); - WindowsEventLogs = dataSourcesSpec.WindowsEventLogs?.Select(x => new PSWindowsEventLogDataSource(x)).ToList(); - Syslog = dataSourcesSpec.Syslog?.Select(x => new PSSyslogDataSource(x)).ToList(); - Extensions = dataSourcesSpec.Extensions?.Select(x => new PSExtensionDataSource(x)).ToList(); - } - } - - /// - /// Wraps the ExtensionDataSource class. - /// - public class PSExtensionDataSource - { - /// - /// Gets or sets list of streams that this data source will be sent to. - /// A stream indicates what schema will be used for this data and - /// usually what table in Log Analytics the data will be sent to. - /// - public IList Streams { get; set; } - - /// - /// Gets or sets the name of the VM extension. - /// - public string ExtensionName { get; set; } - - /// - /// Gets or sets the extension settings. The format is specific for - /// particular extension. - /// - public object ExtensionSettings { get; set; } - - /// - /// Gets or sets the input data sources. The format is specific for - /// particular extension. - /// - public IList InputDataSources { get; set; } - - /// - /// Gets or sets a friendly name for the data source. - /// This name should be unique across all data sources (regardless of - /// type) within the data collection rule. - /// - public string Name { get; set; } - - /// - /// Initializes a new instance of the PSExtensionDataSource class. - /// - public PSExtensionDataSource() - { } - - /// - /// Initializes a new instance of the PSExtensionDataSource class. - /// - /// The ExtensionDataSource to wrap. - public PSExtensionDataSource(ExtensionDataSource extensionDataSource) - { - Streams = extensionDataSource.Streams?.Select(x => x).ToList(); - ExtensionName = extensionDataSource.ExtensionName; - ExtensionSettings = extensionDataSource.ExtensionSettings; - Name = extensionDataSource.Name; - } - } - - /// - /// Wraps the SyslogDataSource class. - /// - public class PSSyslogDataSource - { - /// - /// Gets or sets list of streams that this data source will be sent to. - /// A stream indicates what schema will be used for this data and - /// usually what table in Log Analytics the data will be sent to. - /// - public IList Streams { get; set; } - - /// - /// Gets or sets the list of facility names. - /// - public IList FacilityNames { get; set; } - - /// - /// Gets or sets the log levels to collect. - /// - public IList LogLevels { get; set; } - - /// - /// Gets or sets a friendly name for the data source. - /// This name should be unique across all data sources (regardless of - /// type) within the data collection rule. - /// - public string Name { get; set; } - - /// - /// Initializes a new instance of the PSSyslogDataSource class. - /// - public PSSyslogDataSource() - { } - - /// - /// Initializes a new instance of the PSSyslogDataSource class. - /// - /// The SyslogDataSource to wrap. - public PSSyslogDataSource(SyslogDataSource syslogDataSource) - { - Streams = syslogDataSource.Streams?.Select(x => x).ToList(); - FacilityNames = syslogDataSource.FacilityNames?.Select(x => x).ToList(); - LogLevels = syslogDataSource.LogLevels?.Select(x => x).ToList(); - Name = syslogDataSource.Name; - } - } - - /// - /// Wraps the WindowsEventLogDataSource class. - /// - public class PSWindowsEventLogDataSource - { - /// - /// Gets or sets list of streams that this data source will be sent to. - /// A stream indicates what schema will be used for this data and - /// usually what table in Log Analytics the data will be sent to. - /// - public IList Streams { get; set; } - - /// - /// Gets or sets the interval between data uploads (scheduled - /// transfers), rounded up to the nearest minute. Possible values - /// include: 'PT1M', 'PT5M', 'PT15M', 'PT30M', 'PT60M' - /// - public string ScheduledTransferPeriod { get; set; } - - /// - /// Gets or sets a list of Windows Event Log queries in XPATH format. - /// - public IList XPathQueries { get; set; } - - /// - /// Gets or sets a friendly name for the data source. - /// This name should be unique across all data sources (regardless of - /// type) within the data collection rule. - /// - public string Name { get; set; } - - /// - /// Initializes a new instance of the PSWindowsEventLogDataSource class. - /// - public PSWindowsEventLogDataSource() - { } - - /// - /// Initializes a new instance of the PSWindowsEventLogDataSource class. - /// - /// The WindowsEventLogDataSource to wrap. - public PSWindowsEventLogDataSource(WindowsEventLogDataSource windowsEventLogDataSource) - { - Streams = windowsEventLogDataSource.Streams?.Select(x => x).ToList(); - XPathQueries = windowsEventLogDataSource.XPathQueries?.Select(x => x).ToList(); - Name = windowsEventLogDataSource.Name; - } - } - - /// - /// Wraps the PerfCounterDataSource class. - /// - public class PSPerfCounterDataSource - { - /// - /// Gets or sets list of streams that this data source will be sent to. - /// A stream indicates what schema will be used for this data and - /// usually what table in Log Analytics the data will be sent to. - /// - public IList Streams { get; set; } - - /// - /// Gets or sets the interval between data uploads (scheduled - /// transfers), rounded up to the nearest minute. Possible values - /// include: 'PT1M', 'PT5M', 'PT15M', 'PT30M', 'PT60M' - /// - public string ScheduledTransferPeriod { get; set; } - - /// - /// Gets or sets the number of seconds between consecutive counter - /// measurements (samples). - /// - public int SamplingFrequencyInSeconds { get; set; } - - /// - /// Gets or sets a list of specifier names of the performance counters - /// you want to collect. - /// Use a wildcard (*) to collect a counter for all instances. - /// To get a list of performance counters on Windows, run the command - /// 'typeperf'. - /// - public IList CounterSpecifiers { get; set; } - - /// - /// Gets or sets a friendly name for the data source. - /// This name should be unique across all data sources (regardless of - /// type) within the data collection rule. - /// - public string Name { get; set; } - - /// - /// Initializes a new instance of the PSExtensionDataSource class. - /// - public PSPerfCounterDataSource() - { } - - /// - /// Initializes a new instance of the PSExtensionDataSource class. - /// - /// The PerfCounterDataSource to wrap. - public PSPerfCounterDataSource(PerfCounterDataSource perfCounterDataSource) - { - Streams = perfCounterDataSource.Streams?.Select(x => x).ToList(); - SamplingFrequencyInSeconds = (int)perfCounterDataSource.SamplingFrequencyInSeconds; - CounterSpecifiers = perfCounterDataSource.CounterSpecifiers?.Select(x => x).ToList(); - Name = perfCounterDataSource.Name; - } - } - #endregion - - #region (DCR's child resource) Data Collection Rule Associations - - /// - /// Wraps around an Data Collection Rule Association. - /// - public class PSDataCollectionRuleAssociationProxyOnlyResource : ProxyOnlyResource - { - #region Properties - /// - /// Gets or sets description of the association. - /// - public string Description { get; set; } - - /// - /// Gets or sets the resource ID of the data collection rule that is to - /// be associated. - /// - public string DataCollectionRuleId { get; set; } - - /// - /// Gets the resource provisioning state. Possible values include: - /// 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed' - /// - public string ProvisioningState { get; private set; } - - /// - /// Gets resource entity tag (ETag). - /// - public string Etag { get; private set; } - #endregion - - /// - /// Initializes a new instance of the PSDataCollectionRuleAssociationProxyOnlyResource class. - /// - public PSDataCollectionRuleAssociationProxyOnlyResource() - { } - - /// - /// Initializes a new instance of the PSDataCollectionRuleAssociationProxyOnlyResource class. - /// - /// The DataCollectionRuleAssociationProxyOnlyResource to wrap. - public PSDataCollectionRuleAssociationProxyOnlyResource(DataCollectionRuleAssociationProxyOnlyResource dataCollectionRuleAssociationProxyOnlyResource) - : base( - id: dataCollectionRuleAssociationProxyOnlyResource.Id, - name: dataCollectionRuleAssociationProxyOnlyResource.Name, - type: dataCollectionRuleAssociationProxyOnlyResource.Type) - { - Description = dataCollectionRuleAssociationProxyOnlyResource.Description; - ProvisioningState = dataCollectionRuleAssociationProxyOnlyResource.ProvisioningState; - Etag = dataCollectionRuleAssociationProxyOnlyResource.Etag; - DataCollectionRuleId = dataCollectionRuleAssociationProxyOnlyResource.DataCollectionRuleId; - } - } - #endregion -} \ No newline at end of file diff --git a/src/Monitor/Monitor/OutputClasses/PSDiagnosticSettingCategory.cs b/src/Monitor/Monitor/OutputClasses/PSDiagnosticSettingCategory.cs deleted file mode 100644 index a0be11e5a6db..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSDiagnosticSettingCategory.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - public class PSDiagnosticSettingCategory - { - public string Id { get; private set; } - - public string Name { get; private set; } - - public string Type { get; private set; } - - public PSDiagnosticSettingCategoryType? CategoryType { get; set; } - - public PSDiagnosticSettingCategory() { } - - public PSDiagnosticSettingCategory(DiagnosticSettingsCategoryResource category) - { - this.Id = category?.Id; - this.Name = category?.Name; - this.Type = category?.Type; - if (category != null) - { - switch (category.CategoryType) - { - case Microsoft.Azure.Management.Monitor.Models.CategoryType.Metrics: - this.CategoryType = PSDiagnosticSettingCategoryType.Metrics; - break; - case Microsoft.Azure.Management.Monitor.Models.CategoryType.Logs: - this.CategoryType = PSDiagnosticSettingCategoryType.Logs; - break; - default: - this.CategoryType = null; - break; - } - } - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSDiagnosticSettingOperationResponse.cs b/src/Monitor/Monitor/OutputClasses/PSDiagnosticSettingOperationResponse.cs deleted file mode 100644 index 7751a91f2f24..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSDiagnosticSettingOperationResponse.cs +++ /dev/null @@ -1,29 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Adds the newly added resource as part of the response - /// - public class PSDiagnosticSettingOperationResponse : AzureOperationResponse - { - /// - /// Gets or sets the DiagnosticSettingsResource - /// - public DiagnosticSettingsResource DiagnosticSettingsResource { get; set; } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSEmailReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSEmailReceiver.cs deleted file mode 100644 index 9f6b2246b5e3..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSEmailReceiver.cs +++ /dev/null @@ -1,57 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Commands.Insights.TransitionalClasses; -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the EmailReceiver class. - /// - public class PSEmailReceiver : PSActionGroupReceiverBase - { - /// - /// Gets or sets the receiver's address. - /// - public string EmailAddress { get; set; } - - /// - /// Gets or sets the receiver's status. - /// - public Management.Monitor.Management.Models.ReceiverStatus? Status { get; set; } - - /// - /// Gets or set a value indicating whether common alert schema is to be used or not - /// - public bool UseCommonAlertSchema { get; set; } - - /// Initializes a new instance of the PSEmailReceiver class - public PSEmailReceiver() - { - } - - /// - /// Initializes a new instance of the PSEmailReceiver class. - /// - /// The receiver to wrap. - public PSEmailReceiver(EmailReceiver receiver) - { - this.Name = receiver.Name; - this.EmailAddress = receiver.EmailAddress; - this.Status = TransitionHelpers.ConvertNamespace(receiver.Status); - this.UseCommonAlertSchema = receiver.UseCommonAlertSchema.HasValue ? receiver.UseCommonAlertSchema.Value : false; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSEventHubReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSEventHubReceiver.cs deleted file mode 100644 index 5c1c868bde61..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSEventHubReceiver.cs +++ /dev/null @@ -1,61 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the EventHubReceiver class. - /// - /// - public class PSEventHubReceiver : PSActionGroupReceiverBase - { - /// - /// Gets or sets the SubscriptionId. - /// - public string SubscriptionId { get; set; } - - /// - /// Gets or sets the namespace. - /// - public string EventHubNameSpace { get; set; } - - /// - /// Gets or sets the event hub name. - /// - public string EventHubName { get; set; } - - /// Gets or sets a value indicating whether or not use common alert schema. - public bool UseCommonAlertSchema { get; set; } - - /// Initializes a new instance of the PSEventHubReceiver class - public PSEventHubReceiver() - { - } - - /// - /// Initializes a new instance of the PSEventHubReceiver class. - /// - /// The receiver to wrap. - public PSEventHubReceiver(EventHubReceiver receiver) - { - this.Name = receiver.Name; - this.SubscriptionId = receiver.SubscriptionId; - this.EventHubNameSpace = receiver.EventHubNameSpace; - this.EventHubName = receiver.EventHubName; - this.UseCommonAlertSchema = receiver.UseCommonAlertSchema.HasValue ? receiver.UseCommonAlertSchema.Value : false; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSItsmReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSItsmReceiver.cs deleted file mode 100644 index 0f95e3b7461b..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSItsmReceiver.cs +++ /dev/null @@ -1,55 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Commands.Insights.TransitionalClasses; -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the ItsmReceiver class. - /// - public class PSItsmReceiver : PSActionGroupReceiverBase - { - /// Gets or sets the itsm workspace id of this receiver. - public string WorkspaceId { get; set; } - - /// Gets or sets the itsm connection id of this receiver. - public string ConnectionId { get; set; } - - /// Gets or sets the itsm ticket configuration of this receiver. - public string TicketConfiguration { get; set; } - - /// Gets or sets the itsm region of this receiver. - public string Region { get; set; } - - /// Initializes a new instance of the PSItsmReceiver class - public PSItsmReceiver() - { - } - - /// - /// Initializes a new instance of the PSItsmReceiver class. - /// - /// The receiver to wrap. - public PSItsmReceiver(ItsmReceiver receiver) - { - this.Name = receiver.Name; - this.WorkspaceId = receiver.WorkspaceId; - this.ConnectionId = receiver.ConnectionId; - this.TicketConfiguration = receiver.TicketConfiguration; - this.Region = receiver.Region; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSLogicAppReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSLogicAppReceiver.cs deleted file mode 100644 index ca2e401464ea..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSLogicAppReceiver.cs +++ /dev/null @@ -1,54 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the LogicAppReceiver class. - /// - public class PSLogicAppReceiver : PSActionGroupReceiverBase - { - /// - /// Gets or sets the resourceId. - /// - public string ResourceId { get; set; } - - /// - /// Gets or sets the callbackUrl. - /// - public string CallbackUrl { get; set; } - - /// Gets or sets a value indicating whether or not use common alert schema. - public bool UseCommonAlertSchema { get; set; } - - /// Initializes a new instance of the PSLogicAppReceiver class - public PSLogicAppReceiver() - { - } - - /// - /// Initializes a new instance of the PSLogicAppReceiver class. - /// - /// The receiver to wrap. - public PSLogicAppReceiver(LogicAppReceiver receiver) - { - this.Name = receiver.Name; - this.ResourceId = receiver.ResourceId; - this.CallbackUrl = receiver.CallbackUrl; - this.UseCommonAlertSchema = receiver.UseCommonAlertSchema.HasValue ? receiver.UseCommonAlertSchema.Value : false; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSMetricSettings.cs b/src/Monitor/Monitor/OutputClasses/PSMetricSettings.cs deleted file mode 100644 index 5b7d56d02cfe..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSMetricSettings.cs +++ /dev/null @@ -1,73 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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.Text; -using System.Xml; -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wrapps around the MetricSettings - /// - public class PSMetricSettings : PSDiagnosticDetailSettings - { - /// - /// Initializes a new instance of the PSMetricSettings class. - /// - public PSMetricSettings(MetricSettings metricSettings) - { - if (metricSettings != null) - { - this.Category = metricSettings.Category; - this.Enabled = metricSettings.Enabled; - this.RetentionPolicy = new PSRetentionPolicy(metricSettings.RetentionPolicy); - this.TimeGrain = metricSettings.TimeGrain ?? default(System.TimeSpan); - } - this.CategoryType = PSDiagnosticSettingCategoryType.Metrics; - } - - public PSMetricSettings() - { - } - - public System.TimeSpan TimeGrain { get; set; } - - /// - /// A string representation of the PSMetricSettings - /// - /// A string representation of the PSMetricSettings - public override string ToString() - { - StringBuilder output = new StringBuilder(); - output.AppendLine(); - output.AppendLine("Category : " + Category); - output.AppendLine("Enabled : " + Enabled); - output.AppendLine("TimeGrain : " + XmlConvert.ToString((System.TimeSpan)TimeGrain)); - output.Append("RetentionPolicy : " + RetentionPolicy.ToString(1)); - return output.ToString(); - } - - public MetricSettings GetMetricSetting() - { - return new MetricSettings() - { - Enabled = this.Enabled, - Category = this.Category, - RetentionPolicy = this.RetentionPolicy, - TimeGrain = this.TimeGrain - }; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleAlertingAction.cs b/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleAlertingAction.cs deleted file mode 100644 index 9e152990e8e6..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleAlertingAction.cs +++ /dev/null @@ -1,26 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Management.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - - public class PSScheduledQueryRuleAlertingAction : ScheduledQueryRuleAlertingAction - { - public PSScheduledQueryRuleAlertingAction(Microsoft.Azure.Management.Monitor.Models.AlertingAction alertingAction) - : base(alertingAction: alertingAction) - { } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleAznsAction.cs b/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleAznsAction.cs deleted file mode 100644 index 72c8553f6d08..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleAznsAction.cs +++ /dev/null @@ -1,25 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Management.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - public class PSScheduledQueryRuleAznsAction : ScheduledQueryRuleAznsAction - { - public PSScheduledQueryRuleAznsAction(Microsoft.Azure.Management.Monitor.Models.AzNsActionGroup azNsAction) - : base(azNsActionGroup: azNsAction) - { } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleLogMetricTrigger.cs b/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleLogMetricTrigger.cs deleted file mode 100644 index 69b9f2ade06c..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleLogMetricTrigger.cs +++ /dev/null @@ -1,29 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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.Generic; -using System.Text; - -using Microsoft.Azure.Management.Monitor.Management.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - public class PSScheduledQueryRuleLogMetricTrigger : ScheduledQueryRuleLogMetricTrigger - { - public PSScheduledQueryRuleLogMetricTrigger(Microsoft.Azure.Management.Monitor.Models.LogMetricTrigger metricTrigger) - : base(metricTrigger: metricTrigger) - { } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleResource.cs b/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleResource.cs deleted file mode 100644 index 765947c2f130..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleResource.cs +++ /dev/null @@ -1,25 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Management.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - public class PSScheduledQueryRuleResource : ScheduledQueryRuleResource - { - public PSScheduledQueryRuleResource(Microsoft.Azure.Management.Monitor.Models.LogSearchRuleResource scheduledQueryRule) - : base(logSearchRule: scheduledQueryRule) - { } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleSchedule.cs b/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleSchedule.cs deleted file mode 100644 index ec728f6f1935..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleSchedule.cs +++ /dev/null @@ -1,25 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Management.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - public class PSScheduledQueryRuleSchedule : ScheduledQueryRuleSchedule - { - public PSScheduledQueryRuleSchedule(Microsoft.Azure.Management.Monitor.Models.Schedule schedule) - : base(schedule: schedule) - { } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleSource.cs b/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleSource.cs deleted file mode 100644 index 3b6fb3894a16..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleSource.cs +++ /dev/null @@ -1,25 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Management.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - public class PSScheduledQueryRuleSource : ScheduledQueryRuleSource - { - public PSScheduledQueryRuleSource(Microsoft.Azure.Management.Monitor.Models.Source source) - : base(source: source) - { } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleTriggerCondition.cs b/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleTriggerCondition.cs deleted file mode 100644 index 6df22a079457..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSScheduledQueryRuleTriggerCondition.cs +++ /dev/null @@ -1,25 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Management.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - public class PSScheduledQueryRuleTriggerCondition : ScheduledQueryRuleTriggerCondition - { - public PSScheduledQueryRuleTriggerCondition(Microsoft.Azure.Management.Monitor.Models.TriggerCondition triggerCondition) - : base(triggerCondition: triggerCondition) - { } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSServiceDiagnosticSettings.cs b/src/Monitor/Monitor/OutputClasses/PSServiceDiagnosticSettings.cs deleted file mode 100644 index 2e7805913417..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSServiceDiagnosticSettings.cs +++ /dev/null @@ -1,86 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; -using System.Collections.Generic; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wrapps around the DiagnosticSettings - /// - public class PSServiceDiagnosticSettings : DiagnosticSettingsResource - { - /// - /// Sets or gets the Location of the Diagnostic Setting - /// - public string Location { get; set; } - - /// - /// Sets or gets the Tags of the Diagnostic Setting - /// - public IDictionary Tags { get; set; } - - //public new string Id { get; set; } - - //public new string Name { get; set; } = "service"; - - public PSServiceDiagnosticSettings() { } - - public PSServiceDiagnosticSettings(string id = default(string), string name = default(string)) : base(id, name) - { - } - - /// - /// Initializes a new instance of the PSServiceDiagnosticSettings class. - /// - public PSServiceDiagnosticSettings(DiagnosticSettingsResource serviceDiagnosticSettings) - : base( - name: serviceDiagnosticSettings?.Name, - id: serviceDiagnosticSettings?.Id, - type: serviceDiagnosticSettings?.Type, - metrics: serviceDiagnosticSettings?.Metrics, - logs: serviceDiagnosticSettings?.Logs) - { - if (serviceDiagnosticSettings != null) - { - this.StorageAccountId = serviceDiagnosticSettings.StorageAccountId; - this.EventHubName = serviceDiagnosticSettings.EventHubName; - this.ServiceBusRuleId = serviceDiagnosticSettings.ServiceBusRuleId; - this.EventHubAuthorizationRuleId = serviceDiagnosticSettings.EventHubAuthorizationRuleId; - - if (serviceDiagnosticSettings.Metrics != null) - { - this.Metrics = new List(); - foreach (MetricSettings metricSettings in serviceDiagnosticSettings.Metrics) - { - this.Metrics.Add(metricSettings); - } - } - - if (serviceDiagnosticSettings.Logs != null) - { - this.Logs = new List(); - foreach (LogSettings logSettings in serviceDiagnosticSettings.Logs) - { - this.Logs.Add(logSettings); - } - } - - this.WorkspaceId = serviceDiagnosticSettings.WorkspaceId; - this.LogAnalyticsDestinationType = serviceDiagnosticSettings.LogAnalyticsDestinationType; - } - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSSmsReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSSmsReceiver.cs deleted file mode 100644 index 15556fa23a14..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSSmsReceiver.cs +++ /dev/null @@ -1,56 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the SmsReceiver class. - /// - public class PSSmsReceiver : PSActionGroupReceiverBase - { - /// - /// Gets or sets the receiver's country code. - /// - public string CountryCode { get; set; } - - /// - /// Gets or sets the receiver's phone number. - /// - public string PhoneNumber { get; set; } - - /// - /// Gets or sets the receiver's status. - /// - public Management.Monitor.Management.Models.ReceiverStatus? Status { get; set; } - - /// Initializes a new instance of the PSSmsReceiver class - public PSSmsReceiver() - { - } - - /// - /// Initializes a new instance of the PSSmsReceiver class. - /// - /// The receiver to wrap. - public PSSmsReceiver(SmsReceiver receiver) - { - this.Name = receiver.Name; - this.CountryCode = receiver.CountryCode; - this.PhoneNumber = receiver.PhoneNumber; - this.Status = TransitionalClasses.TransitionHelpers.ConvertNamespace(receiver.Status); - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSTestNotificationDetailsResponse.cs b/src/Monitor/Monitor/OutputClasses/PSTestNotificationDetailsResponse.cs deleted file mode 100644 index afdba2ca2a70..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSTestNotificationDetailsResponse.cs +++ /dev/null @@ -1,56 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - using System; - using System.Collections.Generic; - using System.Linq; - - using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; - - /// - /// Wraps around an Action Group. - /// - public class PSTestNotificationDetailsResponse - { - /// Gets or sets the context - public Context Context { get; set; } - - /// Gets or sets the state - public string State { get; set; } - - /// Gets or sets the completedTime - public DateTimeOffset CompletedTime { get; set; } - - /// Gets or sets the createdTime - public DateTimeOffset CreatedTime { get; set; } - - /// Gets or sets the actionDetails - public ICollection ActionDetails { get; set; } - - /// Initializes a new instance of the PSActionGroup class. - /// the action group resource - public PSTestNotificationDetailsResponse(TestNotificationDetailsResponse actionGroupResource) - { - this.Context = actionGroupResource.Context; - this.State = actionGroupResource.State; - this.CreatedTime = DateTime.Parse(actionGroupResource.CreatedTime); - this.CompletedTime = DateTime.Parse(actionGroupResource.CompletedTime); - this.ActionDetails = this.ActionDetails; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSTestNotificationResource.cs b/src/Monitor/Monitor/OutputClasses/PSTestNotificationResource.cs deleted file mode 100644 index abd9f3b73146..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSTestNotificationResource.cs +++ /dev/null @@ -1,141 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - using System.Collections.Generic; - using System.Linq; - - using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; - - /// - /// Wraps around an Action Group. - /// - public class PSTestNotificationResource - { - /// Gets or sets resource group - public string ResourceGroupName { get; set; } - - /// Gets or sets resource group - public string ActionGroupName { get; set; } - - /// - /// Gets or sets the short name of the action group. This will be used - /// in SMS messages. - /// - /// - public string AlertType { get; set; } - - /// - /// Gets or sets the list of email receivers that are part of this - /// action group. - /// - /// - public IList EmailReceivers { get; set; } - - /// - /// Gets or sets the list of SMS receivers that are part of this action - /// group. - /// - /// - public IList SmsReceivers { get; set; } - - /// - /// Gets or sets the list of webhook receivers that are part of this - /// action group. - /// - /// - public IList WebhookReceivers { get; set; } - - /// - /// Gets or sets the list of event hub receivers that are part of this - /// action group. - /// - /// - public IList EventHubReceivers { get; set; } - - /// - /// Gets or sets the list of Itsm receivers that are part of this - /// action group. - /// - /// - public IList ItsmReceivers { get; set; } - - /// - /// Gets or sets the list of voice receivers that are part of this - /// action group. - /// - /// - public IList VoiceReceivers { get; set; } - - /// - /// Gets or sets the list of arm role receivers that are part of this - /// action group. - /// - /// - public IList ArmRoleReceivers { get; set; } - - /// - /// Gets or sets the list of AzureFunctionReceivers that are part of this - /// action group. - /// - /// - public IList AzureFunctionReceivers { get; set; } - - /// - /// Gets or sets the list of LogicAppReceivers that are part of this - /// action group. - /// - /// - public IList LogicAppReceivers { get; set; } - - /// - /// Gets or sets the list of AutomationRunbookReceivers that are part of this - /// action group. - /// - /// - public IList AutomationRunbookReceivers { get; set; } - - /// - /// Gets or sets the list of AzureAppPushReceivers that are part of this - /// action group. - /// - /// - public IList AzureAppPushReceivers { get; set; } - - /// Initializes a new instance of the PSActionGroup class. - /// the action group resource - /// The resource group name. - /// The action group name. - public PSTestNotificationResource(NotificationRequestBody actionGroupResource, string resourceGroupName, string actionGroupName) - { - this.ResourceGroupName = resourceGroupName; - this.ActionGroupName = actionGroupName; - this.AlertType = actionGroupResource.AlertType; - this.EmailReceivers = actionGroupResource.EmailReceivers?.Select(o => new PSEmailReceiver(o)).ToList(); - this.SmsReceivers = actionGroupResource.SmsReceivers?.Select(o => new PSSmsReceiver(o)).ToList(); - this.WebhookReceivers = actionGroupResource.WebhookReceivers?.Select(o => new PSWebhookReceiver(o)).ToList(); - this.EventHubReceivers = actionGroupResource.EventHubReceivers?.Select(o => new PSEventHubReceiver(o)).ToList(); - this.ArmRoleReceivers = actionGroupResource.ArmRoleReceivers?.Select(o => new PSArmRoleReceiver(o)).ToList(); - this.ItsmReceivers = actionGroupResource.ItsmReceivers?.Select(o => new PSItsmReceiver(o)).ToList(); - this.VoiceReceivers = actionGroupResource.VoiceReceivers?.Select(o => new PSVoiceReceiver(o)).ToList(); - this.AzureFunctionReceivers = actionGroupResource.AzureFunctionReceivers?.Select(o => new PSAzureFunctionReceiver(o)).ToList(); - this.LogicAppReceivers = actionGroupResource.LogicAppReceivers?.Select(o => new PSLogicAppReceiver(o)).ToList(); - this.AutomationRunbookReceivers = actionGroupResource.AutomationRunbookReceivers?.Select(o => new PSAutomationRunbookReceiver(o)).ToList(); - this.AzureAppPushReceivers = actionGroupResource.AzureAppPushReceivers?.Select(o => new PSAzureAppPushReceiver(o)).ToList(); - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSThresholdRuleCondition.cs b/src/Monitor/Monitor/OutputClasses/PSThresholdRuleCondition.cs deleted file mode 100644 index ca58a73b5d54..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSThresholdRuleCondition.cs +++ /dev/null @@ -1,80 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; -using System; -using System.Text; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wrapps around the ThresholdRuleCondition class - /// - public class PSThresholdRuleCondition : IPSRuleCondition - { - /// - /// Gets or sets the DataSource of the rule condition - /// - public RuleMetricDataSource DataSource { get; set; } - - /// - /// Gets or sets the Operator of the rule condition - /// - public ConditionOperator Operator { get; set; } - - /// - /// Gets or sets the Threshold of the rule condition - /// - public double Threshold { get; set; } - - /// - /// Gets or sets the TimeAggregation operator of the rule condition - /// - public TimeAggregationOperator? TimeAggregation { get; set; } - - /// - /// Gets or sets the WindowSize of the rule condition - /// - public TimeSpan? WindowsSize { get; set; } - - /// - /// Initializes a new instance of the PSThresholdRuleCondition class - /// - /// The rule condition - public PSThresholdRuleCondition(ThresholdRuleCondition ruleCondition) - { - this.DataSource = ruleCondition.DataSource as RuleMetricDataSource; - this.Operator = ruleCondition.OperatorProperty; - this.Threshold = ruleCondition.Threshold; - this.TimeAggregation = ruleCondition.TimeAggregation; - this.WindowsSize = ruleCondition.WindowSize; - } - - /// - /// A string representation of the object - /// - /// - public override string ToString() - { - StringBuilder output = new StringBuilder(); - output.AppendLine(); - output.AppendLine(" DataSource : " + this.DataSource.ToString(indentationTabs: 2)); - output.AppendLine(" Operator : " + this.Operator); - output.AppendLine(" Threshold : " + this.Threshold); - output.AppendLine(" Aggregation operator: " + this.TimeAggregation); - output.Append(" Window size : " + this.WindowsSize); - return output.ToString(); - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSVoiceReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSVoiceReceiver.cs deleted file mode 100644 index 09248c91b76f..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSVoiceReceiver.cs +++ /dev/null @@ -1,47 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Commands.Insights.TransitionalClasses; -using Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the VoiceReceiver class. - /// - public class PSVoiceReceiver : PSActionGroupReceiverBase - { - /// Gets or sets the country code. - public string CountryCode { get; set; } - - /// Gets or sets the phone number. - public string PhoneNumber { get; set; } - - /// Initializes a new instance of the PSVoiceReceiver class - public PSVoiceReceiver() - { - } - - /// - /// Initializes a new instance of the PSVoiceReceiver class. - /// - /// The receiver to wrap. - public PSVoiceReceiver(VoiceReceiver receiver) - { - this.Name = receiver.Name; - this.CountryCode = receiver.CountryCode; - this.PhoneNumber = receiver.PhoneNumber; - } - } -} diff --git a/src/Monitor/Monitor/OutputClasses/PSWebhookReceiver.cs b/src/Monitor/Monitor/OutputClasses/PSWebhookReceiver.cs deleted file mode 100644 index 4328de9e035a..000000000000 --- a/src/Monitor/Monitor/OutputClasses/PSWebhookReceiver.cs +++ /dev/null @@ -1,74 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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 Microsoft.Azure.Management.Monitor.Models; - -namespace Microsoft.Azure.Commands.Insights.OutputClasses -{ - /// - /// Wraps the WebhookReceiver class. - /// - public class PSWebhookReceiver : PSActionGroupReceiverBase - { - /// - /// Gets or sets the receiver's service uri. - /// - public string ServiceUri { get; set; } - - /// - /// Gets or set a value indicating whether common alert schema is to be used or not - /// - public bool UseCommonAlertSchema { get; set; } - - /// - /// Gets or sets a value indicating whether or not use AAD authentication. - /// - public bool UseAadAuth { get; set; } - - /// - /// Gets or sets the webhook app object Id for aad auth. - /// - public string ObjectId { get; set; } - - /// - /// Gets or sets the Identifier uri for aad auth. - /// - public string IdentifierUri { get; set; } - - /// - /// Gets or sets the tenant id for aad auth. - /// - public string TenantId { get; set; } - - /// Initializes a new instance of the PSWebhookReceiver class - public PSWebhookReceiver() - { - } - - /// - /// Initializes a new instance of the PSWebhookReceiver class. - /// - /// The receiver to wrap. - public PSWebhookReceiver(WebhookReceiver receiver) - { - this.Name = receiver.Name; - this.ServiceUri = receiver.ServiceUri; - this.UseCommonAlertSchema = receiver.UseCommonAlertSchema.HasValue ? receiver.UseCommonAlertSchema.Value : false; - this.UseAadAuth = receiver.UseAadAuth ?? false; - this.ObjectId = receiver.ObjectId; - this.IdentifierUri = receiver.IdentifierUri; - this.TenantId = receiver.TenantId; - } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/MetricSettings.cs b/src/Monitor/Monitor/TransitionalClasses/MetricSettings.cs deleted file mode 100644 index 0eb67653aa7a..000000000000 --- a/src/Monitor/Monitor/TransitionalClasses/MetricSettings.cs +++ /dev/null @@ -1,53 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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; - -namespace Microsoft.Azure.Management.Monitor.Management.Models -{ - /// - /// This class is intended to help in the transition between namespaces, since it will be a breaking change that needs to be announced and delayed 6 months. - /// It is identical to the MetricSettings, but in the old namespace - /// - public class MetricSettings : Monitor.Models.MetricSettings - { - /// - /// Gets or sets the RetentionPolicy of the MetricSettings - /// - public new RetentionPolicy RetentionPolicy { get; set; } - - /// - /// Gets or sets the TimeGrain of the MetricSettings - /// - public new TimeSpan TimeGrain { get; set; } - - /// - /// Initializes a new instance of the MetricSettings class. - /// - /// The metric settings - public MetricSettings(Monitor.Models.MetricSettings metricSettings) - : base() - { - if (metricSettings != null) - { - this.Enabled = metricSettings.Enabled; - this.Category = metricSettings.Category; - base.RetentionPolicy = metricSettings.RetentionPolicy; - base.TimeGrain = metricSettings.TimeGrain; - this.RetentionPolicy = metricSettings.RetentionPolicy != null ? new RetentionPolicy(metricSettings.RetentionPolicy) : null; - this.TimeGrain = metricSettings.TimeGrain ?? default(TimeSpan); - } - } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleAlertingAction.cs b/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleAlertingAction.cs deleted file mode 100644 index e78b121e48d8..000000000000 --- a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleAlertingAction.cs +++ /dev/null @@ -1,34 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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. -// ---------------------------------------------------------------------------------- - - -namespace Microsoft.Azure.Management.Monitor.Management.Models -{ - public class ScheduledQueryRuleAlertingAction : Monitor.Models.AlertingAction - { - public ScheduledQueryRuleAlertingAction() : base() - { } - /// - /// Initializes a new instance of the ScheduledQueryRuleAlertingAction class. - /// - /// Specifiy action need to be taken when rule type is Alert - public ScheduledQueryRuleAlertingAction(Monitor.Models.AlertingAction alertingAction) : - base( - severity: alertingAction.Severity, - aznsAction: alertingAction.AznsAction, - trigger: alertingAction.Trigger, - throttlingInMin: alertingAction.ThrottlingInMin) - { } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleAznsAction.cs b/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleAznsAction.cs deleted file mode 100644 index 0b23e4eecb80..000000000000 --- a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleAznsAction.cs +++ /dev/null @@ -1,33 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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. -// ---------------------------------------------------------------------------------- - - -namespace Microsoft.Azure.Management.Monitor.Management.Models -{ - public class ScheduledQueryRuleAznsAction : Monitor.Models.AzNsActionGroup - { - public ScheduledQueryRuleAznsAction() : base() - { } - /// - /// Initializes a new instance of the AznsAction class. - /// - /// The AzNs Details - public ScheduledQueryRuleAznsAction(Monitor.Models.AzNsActionGroup azNsActionGroup) : - base( - actionGroup: azNsActionGroup?.ActionGroup, - emailSubject: azNsActionGroup?.EmailSubject, - customWebhookPayload: azNsActionGroup?.CustomWebhookPayload) - { } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleMetricTrigger.cs b/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleMetricTrigger.cs deleted file mode 100644 index 5e2373529499..000000000000 --- a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleMetricTrigger.cs +++ /dev/null @@ -1,34 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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. -// ---------------------------------------------------------------------------------- - - -namespace Microsoft.Azure.Management.Monitor.Management.Models -{ - public class ScheduledQueryRuleLogMetricTrigger : Monitor.Models.LogMetricTrigger - { - public ScheduledQueryRuleLogMetricTrigger() : base() - { } - /// - /// Initializes a new instance of the ScheduledQueryRuleLogMetricTrigger class. - /// - /// The Log Metric Trigger Details - public ScheduledQueryRuleLogMetricTrigger(Monitor.Models.LogMetricTrigger metricTrigger) : - base( - thresholdOperator: metricTrigger?.ThresholdOperator, - threshold: metricTrigger?.Threshold, - metricTriggerType: metricTrigger?.MetricTriggerType, - metricColumn: metricTrigger?.MetricColumn) - { } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleResource.cs b/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleResource.cs deleted file mode 100644 index 1a915753e22c..000000000000 --- a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleResource.cs +++ /dev/null @@ -1,42 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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. -// ---------------------------------------------------------------------------------- - - -namespace Microsoft.Azure.Management.Monitor.Management.Models -{ - public class ScheduledQueryRuleResource : Monitor.Models.LogSearchRuleResource - { - public ScheduledQueryRuleResource() : base() - { } - /// - /// Initializes a new instance of the ScheduledQueryRuleSchedule class. - /// - /// Definition of ScheduledQueryRule. - public ScheduledQueryRuleResource(Monitor.Models.LogSearchRuleResource logSearchRule) : - base( - description: logSearchRule.Description, - enabled: logSearchRule.Enabled, - lastUpdatedTime: logSearchRule.LastUpdatedTime, - provisioningState: logSearchRule.ProvisioningState, - source: logSearchRule.Source, - schedule: logSearchRule.Schedule, - action: logSearchRule.Action, - location: logSearchRule.Location, - id: logSearchRule.Id, - name: logSearchRule.Name, - tags: logSearchRule.Tags, - type: logSearchRule.Type) - { } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleSchedule.cs b/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleSchedule.cs deleted file mode 100644 index 3a98a7242985..000000000000 --- a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleSchedule.cs +++ /dev/null @@ -1,32 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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. -// ---------------------------------------------------------------------------------- - - -namespace Microsoft.Azure.Management.Monitor.Management.Models -{ - public class ScheduledQueryRuleSchedule : Monitor.Models.Schedule - { - public ScheduledQueryRuleSchedule() : base() - { } - /// - /// Initializes a new instance of the ScheduledQueryRuleSchedule class. - /// - /// Defines how often to run the search and the time interval. - public ScheduledQueryRuleSchedule(Monitor.Models.Schedule schedule) : - base( - frequencyInMinutes: schedule.FrequencyInMinutes, - timeWindowInMinutes: schedule.TimeWindowInMinutes) - { } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleSource.cs b/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleSource.cs deleted file mode 100644 index e2ac0403570c..000000000000 --- a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleSource.cs +++ /dev/null @@ -1,38 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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. -// ---------------------------------------------------------------------------------- - - -namespace Microsoft.Azure.Management.Monitor.Management.Models -{ - /// - /// This class is intended to help in the transition between namespaces, since it will be a breaking change that needs to be announced and delayed 6 months. - /// It is identical to the Source, but in the old namespace - /// - public class ScheduledQueryRuleSource : Monitor.Models.Source - { - public ScheduledQueryRuleSource() : base() - { } - /// - /// Initializes a new instance of the ScheduledQueryRuleSource class. - /// - /// The Source of the ScheduledQueryRule object - public ScheduledQueryRuleSource(Monitor.Models.Source source) : - base( - query: source?.Query, - dataSourceId: source?.DataSourceId, - authorizedResources: source?.AuthorizedResources, - queryType: source?.QueryType) - { } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleTriggerCondition.cs b/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleTriggerCondition.cs deleted file mode 100644 index d6cb696f4382..000000000000 --- a/src/Monitor/Monitor/TransitionalClasses/ScheduledQueryRuleTriggerCondition.cs +++ /dev/null @@ -1,33 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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. -// ---------------------------------------------------------------------------------- - - -namespace Microsoft.Azure.Management.Monitor.Management.Models -{ - public class ScheduledQueryRuleTriggerCondition : Monitor.Models.TriggerCondition - { - public ScheduledQueryRuleTriggerCondition() : base() - { } - /// - /// Initializes a new instance of the ScheduledQueryRuleTriggerCondition class. - /// - /// The condition that results in the Log Search rule. - public ScheduledQueryRuleTriggerCondition(Monitor.Models.TriggerCondition triggerCondition) : - base( - thresholdOperator: triggerCondition.ThresholdOperator, - threshold: triggerCondition.Threshold, - metricTrigger: triggerCondition.MetricTrigger) - { } - } -} diff --git a/src/Monitor/Monitor/TransitionalClasses/TransitionHelpers.cs b/src/Monitor/Monitor/TransitionalClasses/TransitionHelpers.cs index 89591688f531..52e9c2ff9711 100644 --- a/src/Monitor/Monitor/TransitionalClasses/TransitionHelpers.cs +++ b/src/Monitor/Monitor/TransitionalClasses/TransitionHelpers.cs @@ -179,28 +179,6 @@ static public Management.Monitor.Management.Models.RuleDataSource ToMirrorNamesp return null; } - static public Management.Monitor.Management.Models.ReceiverStatus? ConvertNamespace(ReceiverStatus? operatorType) - { - if (operatorType.HasValue) - { - int value = (int)operatorType; - return (Management.Monitor.Management.Models.ReceiverStatus)value; - } - - return null; - } - - static public ReceiverStatus? ConvertNamespace(Management.Monitor.Management.Models.ReceiverStatus? operatorType) - { - if (operatorType.HasValue) - { - int value = (int)operatorType; - return (ReceiverStatus)value; - } - - return null; - } - static public Management.Monitor.Management.Models.TimeAggregationOperator? ConvertNamespace(TimeAggregationOperator? operatorType) { if (operatorType.HasValue)